函数 compareText #
词典式比较两个字符串。比较区分大小写。当 x > y 时返回 1,当 x < y 时返回 -1,当 x == y 时返回 0。
对于矩阵,该函数逐元素求值。
Syntax #
math.compareText(x, y)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
string | Array | DenseMatrix | 第一个要比较的字符串 |
y |
string | Array | DenseMatrix | 第二个要比较的字符串 |
Returns #
| Type | Description |
|---|---|
| number | Array | DenseMatrix | 返回比较结果:当 x > y 时为 1,当 x < y 时为 -1,当 x == y 时为 0。 |
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]