Is it intransitive? Can you give a, b, c s.t. a < b and b < c, but not a < c?
To make a point, here is a sorting function I'm using.
static int cmp_seqnos(const void *a, const void *b)
{
uint64_t x = (const uint64_t *) a;
uint64_t y = (const uint64_t *) b;
if (y - x < ((uint64_t) 1 << 63))
return -1;
return x != y;
}
I think this should work if there are uint64_t a, b: b - a < ((uint64_t) 1 << 63) and all values x from the set to be sorted are in the range a..b. Note that a < b isn't a requirement here.Sorting such numbers can be useful when dealing with sliding windows.