Example 1 — Official English Natural Sort
Numbers and names in human order — the sample from the Ramda docs.
const unsorted = ['3', '1', '10', 'Ørjan', 'Bob', 'Älva'];
console.log(R.sort(R.ascendNatural('en', R.identity), unsorted)); How It Works
- Locale + getter.
'en'sets English collation;R.identitycompares each string as-is. - Numeric digits.
localeComparewithnumeric: trueputs'1','3', then'10'. - Letter order. English places Ä before B, then Ørjan.
- Immutable.
R.sortreturns a new array;unsortedis unchanged.
