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

  • Select an input field. (Any)
  • Select an input field. (Any)
  • Enter an output field name. (Long)
  • Click OK.

Examples

Field 1 inputField 2 inputCompare() returns
Numbers
12-1
4564560
100.420.8293921
Strings
AB-1
AA0
BA1
Aa-1
I like automation!I like software!-1
I like automation!I like AutomationHero!1
Boolean
falsetrue-1
truetrue0
truefalse1
Dates_Time
2021-04-01 00:00:00.0002021-05-01 00:00:00.000-1
2021-05-01 00:00:00.0002021-05-01 00:00:00.0000
2021-05-01 02:00:00.0002021-05-01 01:00:00.0001

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. 


Type

Formulas