Creates Selection Sort function