My first crack at a sorting algorithm