Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: More Sorted Business with Hashes

by I0 (Priest)
on Dec 22, 2001 at 05:46 UTC ( [id://133930] : note . print w/replies, xml ) Need Help??


in reply to More Sorted Business with Hashes

-values=> [sort{$clients{$a} <=> $clients{$b}}keys %clients],

Replies are listed 'Best First'.
Re^2: More Sorted Business with Hashes
by Aristotle (Chancellor) on Dec 23, 2001 at 01:57 UTC
    Almost.
    -values=> [sort{$clients{$a} cmp $clients{$b}}keys %clients],
    Note the use of cmp (which sorts alphanumerically) rather than <=> (which sorts numerically). Because Spenser has non-numerals as hash values, <=> will produce seemingly unsorted results.