genericifying the insertion sort