Once upon a time…
In autumn 2001, Leon maintained a web service,
which provided a feed of tweets.
Wait, there was no Twitter in 2001!
Well, the web service had a newsfeed or something like that.
Important is that the records had been sorted chronologically.
Everything was OK until once Leon saw the following
(notice the weird successor of ‘10:43’):
What the hell is going on?
Certainly there is a sort call in code that compares timestamps!
September 9, 2001 the 1000000000th second of Unix epoch occured,
so timestamps became 10-digit decimal numbers instead of 9-digit decimals.
There is a funny thing about comparing numbers:
you may compare them lexicographically,
and as long as they have the same amount of digits, the result is correct.
But if you compare two numbers of different length as strings,
the result differs from numerical comparison.
The weird order of records in our story was produced by lexicographic sorting by timestamps.