A normal, ascending sort would be
my @keys = sort { $a <=> $b } keys(%gene_pool);
The criterion function, should return:
an integer less than 0: if $a is to be sorted before the $b 0: if $a and $b are equal an integer greater than 0: if $a is to be sorted after $b
The "spaceship operator" does just that. To reverse order, just use $b <=> $a for example
Alex
Am Dienstag, 05.08.03 um 17:12 Uhr schrieb Adam Witney:
Hi,
I have a hash with keys of the format
sar0011_4 sar0203_3 sar0050_5 sar2001_1 sar0002_9
And I would like to generate a list ordered by the \d\d\d\d bit in the middle. I have this from the perl cookbook
my @keys = sort {criterion()} keys(%gene_pool);
but I don't really know how to approach the criterion() function
Anybody have any suggestions?
Thanks for any help
Adam
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.