Function compareText #
Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.
For matrices, the function is evaluated element wise.
Syntax #
math.compareText(x, y)
Parameters #
Parameter | Type | Description |
---|---|---|
x |
string | Array | DenseMatrix | First string to compare |
y |
string | Array | DenseMatrix | Second string to compare |
Returns #
Type | Description |
---|---|
number | Array | DenseMatrix | Returns the result of the comparison: 1 when x > y, -1 when x < y, and 0 when x == y. |
Throws #
Type | Description —- | ———–
Examples #
math.compareText('B', 'A') // returns 1
math.compareText('2', '10') // returns 1
math.compare('2', '10') // returns -1
math.compareNatural('2', '10') // returns -1
math.compareText('B', ['A', 'B', 'C']) // returns [1, 0, -1]