Solved exercise 2.2 isSorted function