simplified sorting algorithm