isSorted from FP in Scala