implements insertion sort