http://www.perlmonks.org?node_id=60442

Monolith-0 has asked for the wisdom of the Perl Monks concerning the following question:

I want to get the sorted order of a list of values, but not change the original list. I have an index array in which I wish keep track of the values' sorted order.

For example... start with:

@stuff_list = ( 'b','t','e','s','u','i' ); @list_order = ( 0 , 1 , 2 , 3 , 4 , 5 );
then sort and get:
@stuff_list = ( 'b','t','e','s','u','i' ); @list_order = ( 0 , 2 , 5 , 3 , 1 , 4 );
And then use @list_order to access the actual values.

Originally posted as a Categorized Question.