UNPKG

1.15 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function compareText
4
5Compare two strings lexically. Comparison is case sensitive.
6Returns 1 when x > y, -1 when x < y, and 0 when x == y.
7
8For matrices, the function is evaluated element wise.
9
10
11## Syntax
12
13```js
14math.compareText(x, y)
15```
16
17### Parameters
18
19Parameter | Type | Description
20--------- | ---- | -----------
21`x` | string &#124; Array &#124; DenseMatrix | First string to compare
22`y` | string &#124; Array &#124; DenseMatrix | Second string to compare
23
24### Returns
25
26Type | Description
27---- | -----------
28number &#124; Array &#124; DenseMatrix | Returns the result of the comparison: 1 when x > y, -1 when x < y, and 0 when x == y.
29
30
31## Examples
32
33```js
34math.compareText('B', 'A') // returns 1
35math.compareText('2', '10') // returns 1
36math.compare('2', '10') // returns -1
37math.compareNatural('2', '10') // returns -1
38
39math.compareText('B', ['A', 'B', 'C']) // returns [1, 0, -1]
40```
41
42
43## See also
44
45[equal](equal.md),
46[equalText](equalText.md),
47[compare](compare.md),
48[compareNatural](compareNatural.md)
49
\No newline at end of file