[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lhs and rhs in table.sort
- From: Dirk Laurie <dirk.laurie@...>
- Date: Thu, 27 Aug 2015 08:58:50 +0200
2015-08-26 23:47 GMT+02:00 Tim Hill <drtimhill@gmail.com>:
> When the sorter calls your compare function, it is asking
> “Here are two of the items in the list you told me to sort ..
> please tell me which one should come first in the sort?”.
You can supply any function you like as long as it satisfies
the basic rules of ordering.
1. "A must come before B" and "B must come before A"
may not both be true (but may both be false).
2. If "A must come before B" and "B must come before C"
are both true, then "C must come before A" may not also
be true.
If you function is capricious, anything can happen.
1. (Best) The sort routine detects it and give an error.
2. (Bad) The sort routine returns the original items in some
meaningless order.
3. (Worst) The sort routine does not return at all. (I have
been told this but never actually encountered it.)