Wrote insertion sort function from scratch