[BUG] Sort file list case insensitively

- Make the sorting done on the entries list case insensitive.
- Adds integration test.
- Resolves #317
This commit is contained in:
Gusted 2024-02-29 00:09:20 +01:00
parent d0e5af7079
commit 86b46085c7
No known key found for this signature in database
GPG key ID: FD821B732837125F
3 changed files with 70 additions and 0 deletions

View file

@ -5,11 +5,13 @@ package base
import (
"math/big"
"strings"
"unicode/utf8"
)
// NaturalSortLess compares two strings so that they could be sorted in natural order
func NaturalSortLess(s1, s2 string) bool {
s1, s2 = strings.ToLower(s1), strings.ToLower(s2)
var i1, i2 int
for {
rune1, j1, end1 := getNextRune(s1, i1)

View file

@ -20,4 +20,10 @@ func TestNaturalSortLess(t *testing.T) {
test("a-1-a", "a-1-b", true)
test("2", "12", true)
test("a", "ab", true)
// Test for case insensitive.
test("A", "ab", true)
test("B", "ab", false)
test("a", "AB", true)
test("b", "AB", false)
}