Function sort

Sorts an array of version strings in ascending order using compareBuild() (the whole version including build identifier ([+BUILD]) taken into account).

sort(['2.0.2', '1.2.3', '1.2.4', '1.2.4-foo.bar+build.123', '1.2.4-foo.bar+build.1234']) // [ "1.2.3", "1.2.4-foo.bar+build.123", "1.2.4-foo.bar+build.1234", "1.2.4", "2.0.2" ]
  • Parameters

    • list: string[]

      array of version strings

    • 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 string[]

    the sorted array