Re: stable sorting

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu