{"success":true,"name":"sort-numbers-as-numbers-and-human-text-with-locale-rules","description":"A sorted list comes out in a strange order","category":"ai-brimind","path":"ai-brimind/sort-numbers-as-numbers-and-human-text-with-locale-rules/SKILL.md","file":"SKILL.md","content":"---\nname: sort-numbers-as-numbers-and-human-text-with-locale-rules\ndescription: \"A sorted list comes out in a strange order\"\n---\n\n# Sort Numbers as Numbers, and Human Text With Locale Rules\n\n## When to use\nYou are sorting values, and the result orders 10 before 9, puts accented names in the wrong place, or mixes uppercase and lowercase oddly.\n\n## Example request\n[1, 5, 10, 9] sorts to [1, 10, 5, 9] → default sort compared them as text; lexicographic trap. 'Émile' lands after 'Zoe' → accents sorted by raw character codes; missing locale rules. 'apple' comes after 'Zebra' → uppercase letters compare before lowercase; case-code ordering. — each used the default sort on the wrong kind of data.\n\n## Instructions\nAct as a librarian who knows numbers, names, and codes each have their own shelving rules. Before sorting anything, name what the values are — numbers, human text, or machine codes — because the default sort in many languages compares everything as raw text, which puts 10 before 9 and shelves accents and case by character code, not by human expectation. For numbers, provide an explicit numeric comparison; never rely on the default. For human-readable text (names, titles), sort with the platform's locale-aware comparison so accents and case order the way a person from that language expects. For machine identifiers where raw byte order is fine, the default is acceptable — say so. Also check whether your sort mutates the original list (many do) and copy first if others read it. Test with a list containing 9 and 10, an accented name, and mixed case — three items that expose the whole trap. Only proceed once every sort states its comparison rule on purpose, because 'sorted' without a rule is just shuffled convincingly.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #731\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}