Selection Sort Algorithm in PHP

Selection sort algorithm was developed using comparison algorithm. This algorithm picks an element from the left-hand side and finds the smallest element on the right-hand side, finally it swaps the smallest element to its position and it continues the process for each element with direction left to right except the last element. But it's not an efficient on medium or large data sets.

Time Complexity

  • Best complexity: n^2
  • Average complexity: n^2
  • Worst complexity: n^2