Selection sort works by repeatedly finding the largest/smallest element in an array and swapping it into the proper sorted position. It starts by selecting the largest element and swapping it to the end of the array. It then reduces the array size by one and repeats on the smaller subarray until the array size is 1, leaving the array fully sorted. The example demonstrates selection sort by sorting the array [63, 75, 90, 12, 27] through successive swaps of the largest remaining element.