Red Echo

July 3, 2008

When designing a sorting API, the comparison function should always be a parameter. The default case is less useful than a casual glance might suggest.

3 Comments

  1. I agree; even for string sorts it’s not so clear what the default case should be. But should the algorithm also be configurable?

    Comment by charles — July 7, 2008 @ 8:49 am

  2. Isn’t the algorithm the thing that one configures, by supplying a list and a comparator? I can’t think of any other components involved.

    Comment by Mars Saxman — July 8, 2008 @ 6:34 pm

  3. Within seconds after commenting, the silliness of the second sentence became clear. I was referring to the sorting algorithm itself. For a library function, though, it’s most likely that the choices would be limited to stable v. unstable, and that decision would be made in the course of writing code.

    Comment by charles — July 10, 2008 @ 6:48 am