Re: sort constants confusing
- Posted by _tom (admin) Aug 01, 2017
- 2104 views
The English language is not helping at all. We are using words with fuzzy meanings. The word "natural" seems to be a particular problem when used to describe sorting.
The solution is going to be that a few words will be chosen and then defined for use within Euphoria--ignoring the use (and misuse) of the same words elsewhere.
The idea of "stable sorting" is important. Download http://www.rapideuphoria.com/msort.zip. Spock has explained "stable" clearly in the docs that come with Mike Sort.
Here is another idea for your consideration:
To sort values is "to order values into numerical order from small to large."
To collate values is "to order values into a logical order from small to large."
- We sort numbers
There are no arguments as to what number value comes next. Some people call this "natural order". Sorting "up" from small to large is also "natural."
the eu:compare function will sort number values without problem
- we collate alphanumeric values
Collated data does not have to be in number order. When ascii encoded characters are sorted in numerical order the alphabetic order may not agree with everyone's idea of the correct order. Thus we want a "custom sort" that puts characters, into what is for characters, a "natural order". Some call this "lexical order" to distinguish it from number sorting.
We need a custom algorithm to collate values. Collating must consider ascii and utf encoding for characters.
The problem is if I just use "natural" you can not be sure what I mean unless you look at a definition I create for exclusive use in OE.
_tom