http://qs321.pair.com?node_id=232886


in reply to Tedious array sort revisited

It sounds like a bubble sort. If you really can't use perl's sort for some reason ("capricious instructor mandates", getting a feel for perl's array operators, insanity, etc.), then you should at least know that it's quite easy to swap two values in an array with each other :
($array [$element_one], $array [$element_two]) = ($array [$element_two], $array [$element_one])

you should also consult perlop to see how <=> and cmp work, which can considerably reduce the amount of code needed to write your own sorting mechanism.

update


I really think this would have a different outcome if we could see what the actual assignment is. Something's not being communicated correctly. I'm not advocating that the assignment be posted, of course, but this isn't going well for anyone.