Also, sleep() just delegates the sorting responsibility to a scheduler which likely uses on O(log n) heap algorithm to identify the next scheduled event.
Given there's n timers and O(1) operations I'm not sure where the O(n log n) fits in here. Possible in the minimum number of ticks?
http://www.cs.columbia.edu/~nahum/w6998/papers/sosp87-timing...
Production implementation: https://github.com/facebook/folly/blob/master/folly/io/async...
> If we can guarantee that all timers are set for periods less than MaxInterval, this modified algorithm takes O(1) latency for START_TIMER, STOP_TIMER, and PER_TICK_BOOKKEEPING.
I think that puts this in the same class as counting sort.
> Bonkers, brilliant and definitely NSFW.