Originally posted by Ilja Preuss:
That is, for n objects, you will have O(n^2) comparisons, no matter what exactly your algorithm looks like.
Originally posted by Paul Fairhurst:
The OP mentioned a set of rules. Using a single sorting algorithm would only work for one rule.
Originally posted by Ernest Friedman-Hill:
I wouldn't say that; if there's any way to define an ordering consistent with the rules (surely there's some field you can sort on?) then you can sort the list, then just compare each item with its neighbors; that's O(n ln n).