diff options
Diffstat (limited to 'lib/VNWeb/Prelude.pm')
-rw-r--r-- | lib/VNWeb/Prelude.pm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/VNWeb/Prelude.pm b/lib/VNWeb/Prelude.pm index cd95c046..87810ac7 100644 --- a/lib/VNWeb/Prelude.pm +++ b/lib/VNWeb/Prelude.pm @@ -71,6 +71,7 @@ sub import { no strict 'refs'; *{$c.'::RE'} = *RE; *{$c.'::in'} = \∈ + *{$c.'::idcmp'} = \&idcmp; } @@ -113,4 +114,12 @@ sub in { 0 } + +# Compare two vndbids, using proper numeric order +sub idcmp($$) { + my($a1, $a2) = $_[0] =~ /^([a-z]+)([0-9]+)$/; + my($b1, $b2) = $_[1] =~ /^([a-z]+)([0-9]+)$/; + $a1 cmp $b1 || $a2 <=> $b2 +} + 1; |