I have a hash I need sorted..TWICE. I asked this in the chat box but that got confusing, so here's the problem.
I need to sort a hash by values (the values are all whole numbers) but in some cases, many of the hash keys have the same value. How can I then sort these alphabetically?
Unsorted
rock => 3
candle => 25
bug => 3
rain => 12
dust => 17
spider => 12
Using
foreach (sort {$saved_key{$b} cmp $saved_key{$a}} keys %saved_key)
candle => 25
dust => 17
spider => 12
rain => 12
rock => 3
bug => 3
Desired:
candle => 25
dust => 17
rain => 12
spider => 12
bug => 3
rock => 3
If two or more values are the same, I want to sort them alphanumerically. Any help would be much appreciated.