sub KeysByLogins { my $hash = shift; my @temp = map { [ $hash{$_}->{logins}, $_ ] } keys %$hash; print Dumper(\@temp); return map { $_->[1] } sort { $a->[0] <=> $b->[0] } @temp; }