I have been using inferior code for the Selection Sort since 1979. Last night I found the more efficient pseudo code:
Data Structure and Algorithms Selection Sort – Tutorialspoint
Here is my old code for the Selection Sort in C#:

And my new code from the more efficient pseudo code found online:


Both implementations require n * (n – 1) / 2 comparisons which for an array of length 15 is 15 * 14 /2 = 15 * 7 = 105. The second implementation requires typically fewer calls to the swap function.



The first number after the unsorted array is the number of comparisons which is always 105 in our 15-element test cases. The second number is the tally of the swap function calls.





























