rwxrob-dot/scripts/semver-sort

15 lines
241 B
Plaintext
Raw Normal View History

2022-02-09 07:29:05 +00:00
#!/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)