Update selection sort algorithm