in reply to Re: How to sort hash tables alpha-numeric
in thread How to sort hash tables alpha-numeric
sub sorted { return map { $_->[0] } sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] } map { [ $_, split("-", s/^[A-Z]+//) ] } @_; } foreach my $key (sorted(keys %keys)) { print "'$key' => ", $keys{$key}, "\n"; foreach my $subkey (sorted(keys %{$keys{$key}})) { print " '$subkey' => $keys{$key}->{$subkey}\n"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: How to sort hash tables alpha-numeric
by Aragorn (Curate) on Oct 19, 2003 at 10:46 UTC |