Compare
Description
Compares two values and:
- returns -1 if the first value is less than the second value.
- returns 0 if both values are equal.
- returns 1 if the first value is greater than the second value.
The function compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings.
Use
- Input field:
- Select an input field. (Any)
- Or click the icon to enter a static value.
- Select an input field. (Any)
- Input field:
- Select an input field. (Any)
- Or click the icon to enter a static value.
- Select an input field. (Any)
- Output field:
- Enter an output field name. (Long)
Examples
Field 1 input | Field 2 input | Compare() returns |
---|---|---|
Numbers | ||
1 | 2 | -1 |
456 | 456 | 0 |
100.4 | 20.829392 | 1 |
Strings | ||
A | B | -1 |
A | A | 0 |
B | A | 1 |
A | a | -1 |
I like automation! | I like software! | -1 |
I like automation! | I like AutomationHero! | 1 |
Boolean | ||
false | true | -1 |
true | true | 0 |
true | false | 1 |
Dates_Time | ||
2021-04-01 00:00:00.000 | 2021-05-01 00:00:00.000 | -1 |
2021-05-01 00:00:00.000 | 2021-05-01 00:00:00.000 | 0 |
2021-05-01 02:00:00.000 | 2021-05-01 01:00:00.000 | 1 |
Hero Platform_ Example
An example of this function can be found in Hero Platform_'s library of examples.
Download the example titled "function_Compare" to see an example of this function.