Re: stable sorting
- Posted by gertie at visionsix.com Feb 26, 2003
- 439 views
As no one replied, and this is tested and working code, i'll re-post it. If i am on your ignore list, it won't hurt you anyhow. If the game is to reinvent the wheel instead of acknowledging the existing code (you said there was none in the archives, but there is), then just keep ignoring me. Kat On 25 Feb 2003, at 17:02, Juergen Luethje wrote: > > I wrote: > > > Subject: Re: Euphoria 2.4 Alpha-test Release! > > [...] > > 5) Documentation of sort(): > > Nothing special with version 2.4, I just came across it. > > I think it would be valuable to mention, whether or not the sorting > > of sort() is stable, along with a short explanation for beginners, > > what that means. > [...] > > Probably I should have been somewhat more specific. I actually was > thinking more of custom_sort(), than of sort(): > Say I have a list of records with student names and marks, already > sorted by name. Then i want to sort this list by mark, so that students > with the same mark remain listed in alphabetical order. <snip> > Is there a library in the archive, with which this can be achieved? > I didn't find one. Yes, sorttok(). Several examples of sorting multiple fields at the same time are in the readme.html : See: http://www.pell.net/warning/ai/strtok-v2-1.html#sorttok It handles such things as a descending sort in one field, then an ascending sort within that sort, and a descending in that sort, etc,, as many internal sorts as you have fields in the list, mixing up-down sorts as you want. If you want your list not sorted, but you want the trace route thru the list in the sort order you specify, see sortntok(). Strtok v2.2 is due out someday in March 2003. Kat