update sort algorithm