in reply to How do I sort an array by hash value?

use Sort::Key qw(keysort_inplace); keysort_inplace { $lid->{$_} } @id;
As for your second question:
keysort_inplace { /^([^=]*)/; $lid->{$1} } @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 :-)