Hacker News new | ask | show | jobs
by smarks 482 days ago
Interesting. I haven’t seen an infinite loop either, but I can imagine one if a comparator tries to be too “clever” for example if it bases its comparison logic on some external state.

Another common source of comparator bugs is when people compare floats or doubles and they don’t account for NaN, which is unequal to everything, including itself!

In Java, the usual symptom of comparator bugs is that sort throws the infamous “Comparison method violates its general contract!” exception.