insertion sort changed to match with java code