1 |
|
2 |
|
3 | # Function compareText
|
4 |
|
5 | Compare two strings lexically. Comparison is case sensitive.
|
6 | Returns 1 when x > y, -1 when x < y, and 0 when x == y.
|
7 |
|
8 | For matrices, the function is evaluated element wise.
|
9 |
|
10 |
|
11 | ## Syntax
|
12 |
|
13 | ```js
|
14 | math.compareText(x, y)
|
15 | ```
|
16 |
|
17 | ### Parameters
|
18 |
|
19 | Parameter | Type | Description
|
20 | --------- | ---- | -----------
|
21 | `x` | string | Array | DenseMatrix | First string to compare
|
22 | `y` | string | Array | DenseMatrix | Second string to compare
|
23 |
|
24 | ### Returns
|
25 |
|
26 | Type | Description
|
27 | ---- | -----------
|
28 | number | Array | 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
|
34 | math.compareText('B', 'A') // returns 1
|
35 | math.compareText('2', '10') // returns 1
|
36 | math.compare('2', '10') // returns -1
|
37 | math.compareNatural('2', '10') // returns -1
|
38 |
|
39 | math.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 |