It is fairly easy to do. You can use the values function to get back a list of hash elements. eg
my @items = values %srvlistThat will give you a list in a random(ish) order. To sort the list, you can pass the sort function a closure that tell it how to sort. eg
my @sorted_list = sort { $a->{'pctused'} <=> $b->{'pctused'} values %srvlist$a and $b are temporary variables used only within the sort closure, <=> is the spaceship operator which numerically compares numbers. You would use cmp if you where comparing strings.
Edit: Correct an error pointed out by johngg. Thanks
In reply to Re: Sort Hash of Hashes by key value
by chrestomanci
in thread Sort Hash of Hashes by key value
by jgn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |