As the below image illustrates, a sorting algorithm is an algorithm made up of a series of instructions that takes an array as input, performs specified operations on the array, sometimes called a list, and outputs a sorted array. The process starts by setting the value of N to Length of Array and assigning I = 0. Keep this value of I to MinIndex and Set J = I+1. Now assign the value of J to MinIndex and increment the value of J by J++. If the value of j is less than N, then swap the values of I and MinIndex to sort the array.