$cmp
The$cmp operator compares two values and returns an integer indicating their relative order: -1 if the first is less than the second, 0 if they are equal, or 1 if the first is greater than the second.
Input
- An array containing exactly two values to compare
Output
-1if the first value is less than the second value0if the two values are equal1if the first value is greater than the second value
Examples
First Value Less Than Second
-1
Equal Values
0
First Value Greater Than Second
1 if the score field is greater than 85, -1 if it’s less than 85, or 0 if it equals 85
String Comparison
-1 (lexicographic comparison)
