If you want to preserve insertion order then have a look at Hash::Ordered.
It does not allow access to the position of items, though, so might not do all you need in this case.
In reply to Re^2: How to Order an Array's Elements to Match Another Array's Element Order
by swl
in thread How to Order an Array's Elements to Match Another Array's Element Order
by ozboomer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |