mirror of
https://github.com/iib0011/omni-tools.git
synced 2026-11-25 07:04:40 +03:00
Merge pull request #443 from Sushanth012/fix/case-sensitive-list-sort
fix(list): compare full strings in case-sensitive sort
This commit is contained in:
2 files changed
+7
-1
No files matched your search
@@ -60,7 +60,7 @@ function customAlphabeticSort(
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||
} else {
|
||||
// Case-sensitive comparison
|
||||
return a.charCodeAt(0) - b.charCodeAt(0);
|
||||
return a === b ? 0 : a < b ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +183,12 @@ describe('numericSort function', () => {
|
||||
});
|
||||
|
||||
// CASE SENSITIVE TEST
|
||||
it('should compare the full string when prefixes match', () => {
|
||||
const result = alphabeticSort(['az', 'aa'], true, ',', false, true);
|
||||
|
||||
expect(result).toBe('aa,az');
|
||||
});
|
||||
|
||||
it('should sort a list of string (uppercase) in decreasing order with comma separator ', () => {
|
||||
const array: string[] = ['Apple', 'Pineaple', 'Lemon', 'Orange'];
|
||||
const increasing: boolean = false;
|
||||
|
||||
Reference in new issue
Block a user