It seems to me that you want to do this in a perlish way, and that is why you are trying to do it with a foreach loop. However, foreach (@entries) is the wrong type of loop to use for sorting @entries. It can be done, but you're trying to pound a square peg into a round hole. Why? foreach goes through each element of an array, but it doesn't tell you where in the array the elements are located. A sorting routine, by its nature, needs to have at least some information about the location in the array of the elements it's comparing.
foreach $counter (@entries)It's a good idea to use correct names for your variables, lest you confuse yourself. The loop variable in a foreach loop is not a counter, unless the array you're iterating over happens to be a counting sequence.
In reply to Re: Tedious array sort revisited
by no_slogan
in thread Tedious array sort revisited
by gatornek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |