[Edit] Refactorted insertion sort