new loop and insertSort algorithm