in reply to Sorting by Array values, obtaining indices

use Sort::Key qw(nsortkey); my @vals = (3, 7, 5, 0, 2); my @idx = nkeysort { $vals[$_] } 0..$#vals;
BTW, creating the list of numbers with qw uses much more memory than if you create then as integers (or floats) on the first place. On a 32 bit machine, an integer value uses 16 bytes, a float 20 and a dual string&number value around 36.