strings.compare() function

The strings.compare() function compares the lexicographical order of two strings.

*Output data type: Integer*

  1. import "strings"
  2. strings.compare(v: "a", t: "b")
  3. // returns -1

Return values

ComparisonReturn value
v < t-1
v == t0
v > t1

Parameters

v

The string value to compare.

*Data type: String*

t

The string value to compare against.

*Data type: String*

Examples

Compare the lexicographical order of column values
  1. import "strings"
  2. data
  3. |> map(fn: (r) => ({
  4. r with
  5. _value: strings.compare(v: r.tag1, t: r.tag2)
  6. })
  7. )