Implementing the insertion sort