an implementation of insertion sort