Sorting: too different times. Why?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Nov 22 17:05:08 EST 2009


On Sun, 22 Nov 2009 15:08:28 +0000, Duncan Booth wrote:

> n00m <n00m at narod.ru> wrote:
> 
>> And now it's elephants instead of vectors. Def: an elephant is smarter
>> than another one IIF its size is strictly less but its IQ is strictly
>> greater
>> 
>> I.e. you can't compare (2, 8) to (20, 50) or let count them as equally
>> smart elephants.
> 
> and that still isn't a relationship where you can get any meaningful
> order out of sorting them:

Not everything has, or need have, a total order. There are relationships 
which are only partial (i.e. not all the items are comparable), or 
missing transitivity.

A real-world example is pecking order in chickens, or social hierarchies 
in general. Using the > operator to mean "higher ranking", you often get 
non-transitive hierarchies like the following:

A > B, C, D, E
B > C, E
C > D, E
D > B, E

That is, A > B > C > D > E except that D > B also.

Economic preference is also non-transitive: people may prefer X to Y, and 
prefer Y to Z, but prefer Z to X.

It is perfectly legitimate to sort a non-total ordered list, provided you 
understand the limitations, including that the order you get will depend 
on the order you started with.


-- 
Steven



More information about the Python-list mailing list