Re: stable sorting
- Posted by Juergen Luethje <eu.lue at gmx.de> Feb 26, 2003
- 473 views
Hi Pete, you wrote: > On Tue, 25 Feb 2003 17:02:05 +0100, Juergen Luethje <eu.lue at gmx.de> > wrote: > >>> 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. > > Personally, I would never trust a stable sort. Instead, if needed, > (fwiw, I always go with multi-key sort) I would suggest adding an > incrementing integer in place of the rest of the key. > > If that does not help (performance, at a guess, ask yourself why > you are bothering with the original sort / re-sort subsets as they > come out / find a better way to solve the problem (eg store the data > in a database with an index you can just read down in the first place, > or munge/hash all sort keys into minimum bytes possible) > > Pete [...] Thanks for these hints! Best regards, Juergen -- /"\ ASCII ribbon campain | \ / against HTML in | Superstition brings bad luck. X e-mail and news, | / \ and unneeded MIME |