Re: Sorting AofH over hash key(s)...



/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/"
.



Relevant Pages

  • Re: Sorting AofH over hash key(s)...
    ... # from the Perl Cookbook ... Dad-gummit, I *looked* in the PC, and didn't see this... ... That syntax ... makes perfect sense. ...
    (comp.lang.perl.misc)
  • Re: Sorting Question
    ... both numeric only number consisting of string lengths from 4 to 8 AND part ... I am looking for a way to sort our numeric numbers based on length and then ... first language is), or a series of algebraic equations. ... program requires varies - in this case you need the syntax Access requires. ...
    (microsoft.public.access.reports)
  • Re: Sorting Question
    ... both numeric only number consisting of string lengths from 4 to 8 AND part ... I am looking for a way to sort our numeric numbers based on length and then ... first language is), or a series of algebraic equations. ... program requires varies - in this case you need the syntax Access requires. ...
    (microsoft.public.access.reports)
  • Re: Advanced Macros && Preprocessors
    ... nor what sort of "motion" you desire. ... Currently i'm using SAFECALL macro, the syntax is SAFECALL, ... evidently trying to introduce some sort of assertion or error-check, ... exp comment ...
    (comp.lang.c)
  • Re: Startup Outlook Express Via Command Line
    ... There is no provision there to add an attachment, ... but it doesn't with Outlook Express 6. ... sort of syntax that I can think of in the 'attachment' part). ... OE 6 actually works, and if so, what the syntax would be? ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)