I'm a software engineer specializing in user interface design, as opposed to the person who wrote this code, who was apparently a computer programmer specializing in half-assed copy/pasted spaghetti code. It isn't even my job to write code except as necessary to test new ideas, but I'm working on this because I have something called "attention to detail". (and also a lack of billable hours. :shakehead)
I mean really, if you want to find the largest number in a list of numbers, you don't copy those numbers into a new list, sort the list smallest to largest, and then run a search to find the largest number. You just look at each number, keep track of what was the largest number you've run across thus far, and when you get to the end of the list you know what was the largest number in the list.
The only reason the author did it the slow way is because they were able to copy/paste code from another part of the program, intended for a totally different purpose, and bang it around until it did what they needed it to in its new location. Modular code is a great idea if it's actually designed to be modular, and you're not just forcing a square peg into a round hole because it means you won't miss Jerry Springer. Stupid.