in reply to sort exceptions
Here's a slightly more generic version of Abigail's answer.
my %except = ( foot => -1, # sorts first hand => 1, # sorts last ); sub except_sort { return exists $except{$a} ? $except{$a} : exists $except{$b} ? -$except{$b} : $a cmp $b; } my @list = qw/leg hand eye foot jaw finger/; print join(" ", sort except_sort @list), $/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sort hash exceptions
by japhy (Canon) on Jan 26, 2004 at 16:23 UTC | |
by ysth (Canon) on Jan 26, 2004 at 23:01 UTC |