problem 22, two sorting implementations