in reply to Custom "sort" routine

And of course if you have a large number of items to sort, this is a prime example where a Schwartzian Transform or an Orcish Maneuver could come in very handy. A nice overview of various sort strategies can be found in Resorting to Sorting and The sort function.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James