Created
February 12, 2009 17:22
-
-
Save masak/62746 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat test.pl | |
my $a = join "", <>; | |
print "\n"; | |
$h = { | |
'thing1' => { 'Namespaces' => [ qw<b d f> ] }, | |
'thing2' => { 'Namespaces' => [ qw<a c h> ] }, | |
}; | |
for (map { $h->{$_}{Namespaces}[0] } keys %{$h}) { | |
print $_; | |
print "\n"; | |
} | |
# Sort alphabetically on the first namespace | |
sub by_namespace { | |
$h->{$a}{Namespaces}[0] cmp $h->{$b}{Namespaces}[0]; | |
} | |
my @managers = sort by_namespace keys %{$h}; | |
for (@managers) { | |
print $_, "\n"; | |
} | |
$ perl test.pl | |
^D | |
b | |
a | |
thing1 | |
thing2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment