It is used to check whether the sort program sorted correctly or not. It wouldn't sort correctly because when I wrote the code, I made zee leetle airrare, eh? <smile>
I have a Combsort that is quite "brittle", also an iterative Quicksort that is just like glass I swear - used to run fine, but on the newer cpu's and chipsets, it's WAY too touchy. Also, a FAST sort program that was published with an error in it, in Byte Magazine - things like that.
I have no use whatsoever for Selection sort. Never liked it, and on my PC's, it was always the slowest sorter. I view it's algorithm as the worst of any (somewhat popular) sorting algorithm. Pathetic about covers it. (sorry Nominal!).
Bubble sort is OK for small number of things, but mostly, it just has a catchy name. IMO Insertion sort should be the "low end" sorting algorithm, because:
1) It's stable, by design
2) It's very fast with a small number of things to sort, and with values that are already sorted (it happens).
3) It's shorter than Bubble sort after Bubble sort is optimized.
4) It's about 3.5 times faster on random integers, with small arrays, than Bubble sort. (With optimizations, the sorting speeds even out as the size of the array grows larger). By that time, you'll definitely want something better!