first implementation of selection_sort