Re: Am I abusing SORT? It sure ain't working for me....



rif wrote:
So, looking at the hyperspec,

If the key and predicate always return, then the sorting operation
will always terminate, producing a sequence containing the same
elements as sequence (that is, the result is a permutation of
sequence). This is guaranteed even if the predicate does not really
consistently represent a total order (in which case the elements
will be scrambled in some unpredictable way, but no element will be
lost). If the key consistently returns meaningful keys, and the
predicate does reflect some total ordering criterion on those keys,
then the elements of the sorted-sequence will be properly sorted
according to that ordering.

What you would *like* the hyperpsec to say (for your purposes) is that
if the predicate represents a partial order....

aha. what is a partial vs total order? Wait, Google is my friend:

Total order
From Wikipedia, the free encyclopedia

In mathematics, a total order, linear order or simple order on a set X is
>any binary relation on X that is antisymmetric, transitive, and total.
>This means that if we denote one such relation by ≤ then the following
>statements hold for all a, b and c in X:

if a ≤ b and b ≤ a then a = b (antisymmetry)
if a ≤ b and b ≤ c then a ≤ c (transitivity)
a ≤ b or b ≤ a (totality)

OK, I am missing transitivity. And I can fix that by imposing a tougher sort than the application requires (traversal order).

Thanks! You just saved me half a day and an embarrassing bug report. :)

kenny
.



Relevant Pages