Selection sort is a sorting algorithm that works by repeatedly finding the minimum element from an unsorted sublist and putting it at the front. It has the following steps: 1. Start with an unsorted list. 2. Find the minimum element in the list and swap it with the first element. 3. Repeat step 2 for the remaining elements, each time considering one less element at the front that is already in sorted order. The algorithm runs in O(n2) time as the inner loop needs to run n-1 times for n elements. It works for both ascending and descending order by changing the comparison operator in the inner loop.