Implementation of the insertion sort