Selection Sort works by repeatedly finding the minimum element (the 'treasure') from the unsorted part and putting it at the beginning.
We assume the first element (29) is the minimum. Now we scan the rest to see if we're wrong.
10 is smaller than 29. Update our Minimum pointer.
Is 14 < 10? No. Is 37 < 10? No. Is 13 < 10? No. We scanned the whole list.
The smallest item is 10. We drag it to the front (swap with 29). The first position is now sorted.
Now we look at the remaining unsorted part starting at index 1. 29 is our current candidate.
14 is smaller than 29. Update Minimum.
Continue scanning... 37 is huge. But 13? 13 is smaller than 14! Update Min again.
13 is the winner of this round. Swap 13 with the current front (29).
Start at index 2 (14). Scan... 37 > 14. 29 > 14. 14 is already the smallest!
If the minimum is already in place, we just lock it in.
Compare 37 and 29. 29 is smaller. Swap them.
We are left with one element (37). A single element is always sorted. We are done.
Selection Sort is easy to understand but slow (O(n²)). However, it creates the minimum number of swaps (O(n)), which can be useful if *writing* to memory is expensive.
A great starting point, but rarely used in production due to O(n²).