Sorts a set of version strings semantically
semver-sort
can be used from code or from the cli directly.
import * as semver from "https://deno.land/[email protected]/semver/mod.ts";
import { semverSort } from "https://deno.land/x/[email protected]/mod.ts";
const sorted: { version: string; semver: SemVer }[] = semverSort(
"1.12.0",
"1.7",
"2",
"1.13.0",
);
// 2, 1.13.0, 1.12.0, 1.7
Pass line delimited version strings as stdin to have them sorted.
cat test.txt | deno run "https://deno.land/x/[email protected]/main.ts"
deno install "https://deno.land/x/[email protected]/main.ts" -n semver-sort
cat test.txt | semver-sort
cat test.txt | semver-sort | head -n 1
cat test.txt | semver-sort | tail -n +2
Distributed under the Apache 2.0 License. See LICENSE
for more
information.
- Justin Chase
- GitHub: justinmchase
- Email: [email protected]