Selection sort is a simple comparison-based sorting algorithm. It works by repeatedly finding the minimum element (considering ascending order) from the unsorted part and putting it at the beginning.

Steps of Selection Sort:

  1. Initialize the minimum value’s index (min_idx) to the first element’s index of the unsorted subarray.
  2. Iterate through the unsorted subarray to find the actual minimum element.
  3. Swap the found minimum element with the first element of the unsorted subarray.
  4. Move the boundary of the unsorted subarray by one element to the right