in reply to Why programming is so much more than writing code
I can't comment on the naming of the sub, but the substance looks fine, albeit with somewhat quirky indentation. It is clearly a comparison function used to sort a two dimensional array where column importance (for sorting purposes) is in the index order 3, 2, 1, 0, 4.
It might be nice for a comment to say "sort by Name, Social ID number, street address, then eye color", but commenting "sort by columns 4, 3, 2, 1, 5" adds nothing to the code and would likely cause confusion.
There are a few things that could reduce the possibility for error. Using named constants for the column indexes or using a hash for the column entries instead of an array would go a long way to making the code more robust, but wouldn't much change how obvious the intent of this particular routine is.
There may be many nasty things in the code that you are looking at, but this example is really not so awful. The major thing it needs to make it acceptable is a good name.
|
|---|