Sorts an array by repeatedly locating the minimum element of an unsorted part and placing it at the beginning.