Don't take case in count when sorting non-ordered vector flag

Fixes: https://gitlab.cri.epita.fr/ing/majeures/srs/fic/server/-/issues/30
This commit is contained in:
nemunaire 2023-11-05 11:23:58 +01:00
parent 20272e7bad
commit 6fd14306e1
2 changed files with 17 additions and 3 deletions

View File

@ -67,7 +67,10 @@ func getRawKey(input interface{}, validatorRe string, ordered bool, showLines bo
ignord := "f"
if !ordered {
sort.Strings(fitems)
// Sort the list without taking the case in count.
sort.Slice(fitems, func(i, j int) bool {
return strings.ToLower(fitems[i]) < strings.ToLower(fitems[j])
})
ignord = "t"
}

View File

@ -80,9 +80,20 @@
}
}
// Sort cells
// Sort cells (case doesn't count in sort)
if (flag.ignore_order) {
v = v.sort();
v = v.sort((a,b) => {
const aUC = a.toUpperCase();
const bUC = b.toUpperCase();
if (aUC < bUC) {
return -1;
}
if (aUC > bUC) {
return 1;
}
return 0;
});
}
value = v.join(flag.separator ? flag.separator : ',');