mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 16:31:13 +00:00
Repair sort bug (#5462)
* repair chinese number sort bug * optimize code
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { mediaUrl, gettext, serviceURL, siteRoot, isPro, enableFileComment, fileAuditEnabled, canGenerateShareLink, canGenerateUploadLink, shareLinkPasswordMinLength, username, folderPermEnabled, onlyofficeConverterExtensions, enableOnlyoffice } from './constants';
|
||||
import { strChineseFirstPY } from './pinyin-by-unicode';
|
||||
import TextTranslation from './text-translation';
|
||||
import React from 'react';
|
||||
import toaster from '../components/toast';
|
||||
import PermissionDeniedTip from '../components/permission-denied-tip';
|
||||
import { compareTwoString } from './compare-two-string';
|
||||
|
||||
export const Utils = {
|
||||
|
||||
@@ -879,28 +879,7 @@ export const Utils = {
|
||||
// if wordA >= wordB, return 1
|
||||
// if wordA < wordB, return -1
|
||||
|
||||
var a_val, b_val,
|
||||
a_uni = wordA.charCodeAt(0),
|
||||
b_uni = wordB.charCodeAt(0);
|
||||
|
||||
if ((19968 < a_uni && a_uni < 40869) && (19968 < b_uni && b_uni < 40869)) {
|
||||
// both are chinese words
|
||||
a_val = strChineseFirstPY.charAt(a_uni - 19968).toLowerCase();
|
||||
b_val = strChineseFirstPY.charAt(b_uni - 19968).toLowerCase();
|
||||
} else if ((19968 < a_uni && a_uni < 40869) && !(19968 < b_uni && b_uni < 40869)) {
|
||||
// a is chinese and b is english
|
||||
return 1;
|
||||
} else if (!(19968 < a_uni && a_uni < 40869) && (19968 < b_uni && b_uni < 40869)) {
|
||||
// a is english and b is chinese
|
||||
return -1;
|
||||
} else {
|
||||
// both are english words
|
||||
a_val = wordA.toLowerCase();
|
||||
b_val = wordB.toLowerCase();
|
||||
return this.compareStrWithNumbersIn(a_val, b_val);
|
||||
}
|
||||
|
||||
return a_val >= b_val ? 1 : -1;
|
||||
return compareTwoString(wordA, wordB);
|
||||
},
|
||||
|
||||
// compare two strings which may have digits in them
|
||||
|
Reference in New Issue
Block a user