fixed a SelectionSort bug

set sorted boolean to the right place