Fixed isSorted issue