[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:
parent
d0e5af7079
commit
86b46085c7
3 changed files with 70 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue