Sorting an array using insertion sort