[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A strange problem with table.sort()
- From: Alen Ladavac <alenl-ml@...>
- Date: Thu, 26 Jul 2007 15:55:01 +0200
Ketmar wrote:
I have just recalled an interesting fact! Quite some time ago, I wrote
a sorting function for a framework we use internally, and have had a
similar design issue - a comparator function that must return false on
equal objects! Here is excerpt from my old documentation for it:
>> This function must return TRUE _iff_ eA comes after eB in the order
>> that you wish to sort by. (E.g. it would be the same as operator>()
>> for ascending sort of numbers.) Note that the relation must not be
>> reflexive, i.e. IsGT(x,x) must be FALSE, otherwise the algorithm
>> may lock up.
It very decidedly specifies that same problem, yet doesn't seem much
longer than the one from the Lua docs:
>> If comp is given, then it must be a function that receives two
>> table elements, and returns true when the first is less than the
>> second (so that not comp(a[i+1],a[i]) will be true after the sort).
>> If comp is not given, then the standard Lua operator < is used
>> instead.
> i think that Lua manual is close toperfection: it is small, easily
> understandable and complete.
I agree with this, and I'd like it to be even closer to perfection.
Don't want to be too pushy, though, so I'll leave it at this...
Cheers,
Alen