As for your second question:use Sort::Key qw(keysort_inplace); keysort_inplace { $lid->{$_} } @id;
I've taken a liking to the Sort::Key interface :-) Note that if your values that you're sorting by actually are numbers, you can put an "n" in front (nkeysort_inplace), or if they're integers (and fit into the native signed int's) use "i", or if they're unsigned integers (and, again, fit into the native unsigned int's) use "u" in front. If you want to put it into another array instead of replacing the existing @id, just remove _inplace, and assign: @sorted_ids = keysort { ... } @ids. Really nifty stuff :-)keysort_inplace { /^([^=]*)/; $lid->{$1} } @id;
In reply to Re: How do I sort an array by hash value?
by Tanktalus
in thread How do I sort an array by hash value?
by josh097
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |