in reply to Complex conditional sort
[ I'm assuming the key is the colour's name (e.g. "Grey brown mix"). ]
Compare quantities, breaking ties by comparing names:
sort { $products{'Cat'}{'Pro'}{$a}{'Qua'} <=> $products{'Cat'}{'Pro'}{$b} +{'Qua'} || $a cmp $b } keys %{ $products{'Cat'}{'Pro'} }
Repeating $products{'Cat'}{'Pro'} all over the place is a bit silly, though.
my $pro_products = $products{Cat}{Pro}; sort { $pro_products->{$a}{Qua} <=> $pro_products->{$b}{Qua} || $a cmp $b } keys %$pro_products
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Complex conditional sort
by Limbic~Region (Chancellor) on Mar 09, 2011 at 00:22 UTC | |
by ikegami (Patriarch) on Mar 09, 2011 at 00:37 UTC |