It is assumed that the first element in the array is already sorted, the second element in the array is considered as the key and it is compared with all the elements that come before the key in the array. If the key is greater than the 0th element then there is no change else it is swapped .Now the first two elements(0th and 1st) are assumed to be sorted, the third element is chosen as the key , which is then compared with the first two elements and if found that the key is the smallest it is places infront of the array, else it is placed next to the element that is greater than the key
and so on

