tFix edge case with book sorting - lsg - Lumidify Site Generator
HTML git clone git://lumidify.org/lsg.git (fast, but not encrypted)
HTML git clone https://lumidify.org/git/lsg.git (encrypted, but very slow)
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 60cba53ab7684b466185fd3886fb19d22b688e53
DIR parent 07da68d9e0b5a2bb62bf7540dfecfc7df5ee7117
HTML Author: lumidify <nobody@lumidify.org>
Date: Sat, 7 Oct 2023 09:48:04 +0200
Fix edge case with book sorting
Diffstat:
M LSG/UserFuncs.pm | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
DIR diff --git a/LSG/UserFuncs.pm b/LSG/UserFuncs.pm
t@@ -41,8 +41,14 @@ sub sort_numeric {
if ($i > $#s2) {
return 1;
}
- if ($s1[$i] ne $s2[$i]) {
- return ($s1[$i] =~ /\d+/ && $s2[$i] =~ /\d+/) ? $s1[$i] <=> $s2[$i] : $s1[$i] cmp $s2[$i];
+ # 01 and 1 should compare the same, so numbers
+ # need '!=' instead of 'ne' like the strings
+ if ($s1[$i] =~ /\d+/ && $s2[$i] =~ /\d+/) {
+ if ($s1[$i] != $s2[$i]) {
+ return $s1[$i] <=> $s2[$i];
+ }
+ } elsif ($s1[$i] ne $s2[$i]) {
+ return $s1[$i] cmp $s2[$i];
}
}
if ($#s2 > $#s1) {