@Julian_Halliwell You are right. In the context of this thread “Natural Ordering” means something different from what I had in mind, and TBH I didn’t look at the link that @Zackster posted.
Coming from the Java world, natural ordering means what I wrote above [1]:
Comparable implementations provide a natural ordering for a class, which allows objects of that class to be sorted automatically.
For String that would be “Lexicographic” ordering, which seems “natural” to me, but is by no means “human”.
I think that for the sake of clarity, the “Human” part should be emphasized in this thread rather than the “Natural” part.
I still think that the best approach is to enhance the BIF Compare()
, so that instead of
Compare(String1, String2)
Its signature will be
Compare(Object1, Object2, flags)
So that (just throwing ideas here):
Compare("z2", "z10") // yields 1
Compare("z2", "z10", "human") // yields -1
Compare("01/02/2018", "2018-01-15", "date", "en-US") // yields -1 for January 2nd
Compare("01/02/2018", "2018-01-15", "date", "en-UK") // yields 1 for February 1st
Compare("01/02/2018", "2018-01-15", "date") // yields -1 for me and 1 for you, assuming US and UK locales, respectively