This Commented CUE
demonstrates how to use the built-in function
list.IsSortedStrings
to test and report if lists of strings are sorted alphabetically.
file.cue
package example
import "list"
_unsorted: ["B", "C", "A"]
_sorted: ["A", "B", "C"]
testUnsorted: list.IsSortedStrings(_unsorted)
testSorted: list.IsSortedStrings(_sorted)
TERMINAL
$ cue eval
testUnsorted: false
testSorted: true
Related content
- How-to Guide: Using "list.IsSortedStrings" as a field validator
- How-to Guide: Using "list.IsSorted" to report if lists are sorted
- The
list
built-in package