Implemented selection sort algorithm