Selection sort is a simple comparison-based sorting algorithm. It is in-place and needs no extra memory. The idea behind this algorithm is pretty simple. The array is divided into two parts: sorted and unsorted. The left part is sorted subarray and the right part is unsorted subarray. Initially, sorted subarray is empty and unsorted array is the complete given array.