I\'m looking for a nice way to sort a hash in Perl by value first and by key afterwards.
Example:
my %userids = (
williams => \"Marketing\",
smit
Good reference: http://www.misc-perl-info.com/perl-sort.html#shv
#!/usr/bin/perl
my %userids = (
williams => "Marketing",
smith => "Research",
johnson => "Research",
jones => "Marketing",
brown => "Marketing",
davis => "Research"
);
foreach (sort { ($userids{$a} cmp $userids{$b}) || ($a cmp $b) } keys %userids)
{
print "$_: $userids{$_}\n";
}