begin selection sort. IO should most likely be done not here even though I have started it here.