rwxrob-dot/scripts/semver-sort
Rob Muhlestein 2ea0289e9f Rebase
2022-02-09 02:29:05 -05:00

15 lines
241 B
Perl
Executable File

#!/usr/bin/perl
# Sorts simple semantic versions.
use v5.18;
my @versions = <STDIN>;
sub num {
$_ = shift;
s/^v//;
sprintf "%09i%09i%09i", split /\./;
}
print(grep {s,^,v,} sort {num($a) <=> num($b)} grep {s,^v,,} @versions)