Implemented isSorted