The author spent days thinking about it, whereas sorting is the immediate obvious answer. Developer time is massively more valuable than computer time by a factor of 1000
And the clever approach only works on data that is perfect, and that’s extremely rare in the real world