Prefix sorting