Selection sort doubt

I’m not able to understand this method
Pls explain me or else give other method

selection sort is one of the easiest sorting algorithm

How Selection Sort Works?

  1. Set the first element as minimum .

Select first element as minimum

  1. Compare minimum with the second element. If the second element is smaller than minimum , assign the second element as minimum .

Compare minimum with the third element. Again, if the third element is smaller, then assign minimum to the third element otherwise do nothing. The process goes on until the last element.

Compare minimum with the remaining elements

  1. After each iteration, minimum is placed in the front of the unsorted list.

Swap the first with minimum

  1. For each iteration, indexing starts from the first unsorted element. Step 1 to 3 are repeated until all the elements are placed at their correct positions.

The first iteration

The second iteration

The third iteration

The fourth iteration

Selection Sort Algorithm

selectionSort(array, size)
  repeat (size - 1) times
  set the first unsorted element as the minimum
  for each of the unsorted elements
    if element < currentMinimum
      set element as new minimum
  swap minimum with first unsorted position
end selectionSort

if you want to ask something about this feel free to ask
i hope this helps
if yes show your response with :heart: and don’t forgot to mark doubt as resolved