Fixed function sorting problem