insertion sort without error-prone C arrays