Function rcompare

The reverse of compare.

versionArray.sort(rcompare) can sort in descending order for MAJOR.MINOR.PATCH[-PRERELEASE], excluding build identifier ([+BUILD]). This is different from rsort(), which also sorts in descending order but for the whole MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]

rcompare('1.2.3', '1.2.4') // 1
  • Parameters

    • v1: string

      first version string

    • v2: string

      second version string

    • OptionaloptionsOrLoose: boolean | Options

      an options object { loose } (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings

    Returns -1 | 0 | 1

    • 0 if v1 == v2
    • -1 if v1 > v2
    • 1 if v1 < v2