Dr. Mu has asked for the wisdom of the Perl Monks concerning the following question:
where &foo returns the field or aspect of each item being sorted on (and where a Schwartzian Transform would be performed if @orig is sufficiently long and &foo is sufficiently complicated).@sorted = sort {&foo($orig[$a]) cmp &foo($orig[$b]) || $a <=> $b} (0 . +. @orig - 1)
(The best answer will end up as a margin note in my camel book.)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: The Effect of sort on Equal Items
by BrowserUk (Patriarch) on Oct 03, 2002 at 04:15 UTC | |
Re: The Effect of sort on Equal Items
by Zaxo (Archbishop) on Oct 03, 2002 at 04:39 UTC | |
by Dr. Mu (Hermit) on Oct 03, 2002 at 05:21 UTC |