compute selection sort