#perl - Mon 23 Apr 2007 between 23:49 and 23:58



revdiabloPacking them all into one key just doesn't make me feel warm inside
f00li5hrevdiablo: see where it says # same thing using a Schwartzian Transform (no temps)
in that article
you simply add more or's to the bit below
revdiablof00li5h: It needs to be an arbitrary number of keys
f00li5h: A general purpose routine that takes a list of 1 or more keys, and makes a sort that does that
buurevdiablo: Isn't there a cpan module to do this?
Sort::Maker perhaps
f00li5hrevdiablo: replace that with a calal to a compare
revdiabloI don't know. I would use it if I knew what it was
buuSort::ArbBiLex
f00li5hrevdiablo: pass it a subref
buuEtc.
revdiablof00li5h: I want it to take the keys to sort from @ARGV
f00li5hrevdiablo: where are you getting the hashes?
revdiabloThe hashes are lists of files and associated attributes
path, name, mtime, etc
f00li5hhow do you know wether to compare as strings or numeric?
revdiabloThey are all numeric for now
f00li5hi see
revdiabloI'm sorting by times and sizes
f00li5hwhile($key = shift @list){ $a->{key} <=> $b->{$key} }
that's no good
$key = shift @list until ( $a->{$key} <=> $b->$key );
# returns first non-zero comparison, or zero if they're equal
revdiabloMaybe something recursive would do. sub try_another_from_list { return unless @_; my @list = @_; my $key = shift; $a->{$key} <=> $b->{$key} || try_another_from(@list) }
f00li5hthat'd do it

Page: 2 9 16 23 30 37 44 51 58 65 72 79 86 

IrcArchive