The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hashes are one way by their nature, so you can only do a sort (that results in a "sorted hash") based on the upstream (key) end.
You can sort the hash by key or value, as you have done in (#1) and (#2) --- (in reality you're returning a list of keys corresponding to the hash ordered by key(#1) or value(#2).)
In (#3) you are not sorting the hash, you are sorting the values in the hash and discarding the keys. This gets you a sorted value list (which may be all you want, depending on the application) In (#4) you are passing the sort function the values in the hash and trying to use them like keys. (again, discarding the actual keys). Hopefully it is obvious now that this will not do anything useful. -Greg In reply to Re: Sort: By keys, values, and their returning values.
by Anonymous Monk
|
|