Hacker News new | past | comments | ask | show | jobs | submit login

Bubble sort is the fastest sort for sets of size two.

Now, arguably there isn't really much functional difference between sorts on sets of size two, but the simplicity of bubble sort gives it an advantage for this extreme case.




That generally applies to anywhere you're coding in something raw like C or assembly on very small datasets and don't want to deal with the mental overhead of picking and writing an efficient sorting algorithm. For sets of less than 100 items, it's not worth the bother.

I actually did that in a programming contest once, having solved the hard part of the problem and being left with nothing but sorting the results.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: