Re: Sorting AofH over hash key(s)...
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 02:13:54 GMT
/usr/ceo <newsbot@xxxxxxx> wrote:
On Oct 30, 4:03 pm, nolo contendere <simon.c...@xxxxxxx> wrote:
On Oct 30, 4:40 pm, "/usr/ceo" <news...@xxxxxxx> wrote:
[Problem description snipped]
# from the Perl Cookbook
my @sorted =
sort { $a->name cmp $b->name
||
$b->age <=> $a->age } @employees;
Dad-gummit, I *looked* in the PC, and didn't see this... That syntax
makes perfect sense. It never occurred to me to extended the { sort
$a->{key} cmp $b->{key} } syntax into something broader with logical
operators. You get stuck in a rut with what you see as 90% used
sometimes.
NOW the solution is on the internet... :-)
Errr, it was already on the internet...
http://faq.perl.org/perlfaq4.html#How_do_I_sort_a_hash
.... and on your very own hard disk!
perldoc -q sort
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
.
- References:
- Sorting AofH over hash key(s)...
- From: /usr/ceo
- Re: Sorting AofH over hash key(s)...
- From: nolo contendere
- Re: Sorting AofH over hash key(s)...
- From: /usr/ceo
- Sorting AofH over hash key(s)...
- Prev by Date: Re: configurable variables in own file?
- Next by Date: Re: configurable variables in own file?
- Previous by thread: Re: Sorting AofH over hash key(s)...
- Next by thread: Re: Sorting AofH over hash key(s)...
- Index(es):
Relevant Pages
|