The default sort order is alphabetic, rather than numeric, regardless of the types in the array. Specifically, even if an array contains only numbers, all values in it will be converted to strings and sorted lexicographically, for an order like this: 1, 15, 2, 20, 5.
Even to sort strings, the default sort order may give unexpected results. Not only does it not support localization, it also doesn't fully support Unicode, as it only considers UTF-16 code units. For example, in the code below, `"eΔ"` is surprisingly before and after `"éΔ"`.
Fortunately the ``++sort++`` and ``++toSorted++`` methods allow you to pass an optional compare function to specify the sort order. When a compare function is supplied, the returned order depends on the return value of the compare function.
\[~ann.campbell.2] Assign for review and completion
=== on 28 Apr 2015, 13:28:08 Ann Campbell wrote:
Double-check my changes, please [~linda.martin]
Also, do you plan to raise this on all arrays, or limit it to when you can tell the array contains numbers?
=== on 29 Apr 2015, 09:16:26 Linda Martin wrote:
\[~ann.campbell.2] That's a good question. I think we'll do a first implementation and see what are the results and narrow the scope if too much FP shows up.