From 597f181523ccf1d990a699aee3c20034e3a13ecf Mon Sep 17 00:00:00 2001 From: lace <> Date: Mon, 24 Dec 2007 16:54:32 +0000 Subject: [PATCH] Sort in the (approx.?) rpm versioning order. --- bin/sortn | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 bin/sortn diff --git a/bin/sortn b/bin/sortn new file mode 100755 index 0000000..bf87d95 --- /dev/null +++ b/bin/sortn @@ -0,0 +1,24 @@ +#! /usr/bin/perl +# $Id$ + +use strict; +use warnings; +print sort { + my $a=$a; + my $b=$b; + while ($a ne "" || $b ne "") { + $a=~s/^(\D+)//s; + my $as=$1; + $b=~s/^(\D+)//s; + my $bs=$1; + my $rs=$as cmp $bs; + return $rs if $rs; + $a=~s/^(\d+)//s; + my $an=$1; + $b=~s/^(\d+)//s; + my $bn=$1; + my $rn=$an<=>$bn; + return $rn if $rn; + } + return 0; +} @ARGV ? map "$_\n",@ARGV : <>; -- 1.8.3.1