in reply to sorting and indicies
Your list is called "@list". This requires you to refer to its elements as $list[?] . This means that the sorting routine should be:
my @indicies = sort { $list[$a] <=> $list[$b] ) 0.. $#list;
If we read the line, it says:
- @indicies is the new array
- The sort is going to sort numbers from 0 to the highest index in "@list"
- But the sorting comparision (the stuff in the curlies) is going to compare the values inside @list rather than the indicies themselves. However, it will reoder the indicies to create your new array.
Much greater detail is found in man perlfunc and also on the sort documents on this site.
-- termix
|
---|
In Section
Seekers of Perl Wisdom