|
|
|
Your skill will accomplish what the force of many cannot |
|
| PerlMonks |
Re^2: Stable sorting in Perl (old)by tye (Sage) |
| on Aug 27, 2003 at 15:24 UTC ( [id://287141]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
In case you aren't on the leading edge of Perl versions and don't have sort.pm, you can get a stable sort fairly easily: For a more complex form of sort: Note that this allows us to avoid the RESTORE() step which often means that the XFORM() step becomes much simpler. If you are going for speed by avoiding COMPARE() [the advantage of which has been reduced (but not eliminated) for some cases due to new optimizations], then consider:
Which may become my favorite sorting technique because it gives you almost maximum speed while not requiring RESTORE() (which is often the hardest part). I like it so much, I've made it an official snippet: fast, flexible, stable sort. (updated.) - tye
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||