strings.compare() function

Warning! This page documents an earlier version of Flux, which is no longer actively developed. Flux v0.50 is the most recent stable version of Flux.

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

Output data type: Integer

import "strings"

strings.compare(v: "a", t: "b")

// returns -1

Return values

Comparison Return value
v < t -1
v == t 0
v > t 1

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
import "strings"

data
  |> map(fn: (r) => ({
      r with
      _value: strings.compare(v: r.tag1, t: r.tag2)
    })
  )