Selection sort

Selection Sort is a simple and intuitive sorting algorithm. It works as follows: select the smallest (or largest) element from the data elements to be sorted for the first time, store it at the beginning of the sequence, and then find the smallest (or largest) element from the remaining unsorted elements, and then put it at the end of the sorted sequence. And so on, until the total number of data elements to be sorted is zero.

advantage

emmm… It doesn’t seem to have any advantages, except that it’s a little better than bubble sort, right

Demo animation

Sort a regular array

View slow demos, code, test cases

Sort an almost sorted array

View slow demos, code, test cases