in reply to Sort assoc array
Or in the context of a loop:my @sorted = sort keys %hash;
foreach my $key (sort keys %hash) { # Do something with $hash{key}; }
You can also sort the keys by the value they point to...
my @sortedkeys = sort { $hash{$a} cmp $hash{$b} } keys %hash;
The point is, that you pretty much want to think in terms of unsorted hashes with (when needed) a list of sorted keys.
Dave
|
|---|