exercise 2.2 - implement isSorted function