in reply to Sort array + keep associated indexes in other array

Consider building a list or hash of structures that are strictly for the purpose of sorting, containing references (or undef as the case may be) to the detailed records.   Your list might therefore be as in your example [ {name=>"cow", weight_record=>some_reference}, ... ].   A hash structure might be handiest.   This structure exists simply for the purpose of, and when, you are preparing the final sorted output.   It contains references to the data that will go into that output.   It is structured in whatever way is conducive to the purpose of arranging the output, drawing its data from other existing data structures which remain conducive to the data-preparation operations which preceded it.
  • Comment on Re: Sort array + keep associated indexes in other array