/** @format */

import {chinesePattern} from '../const/regular';
/**
 * 排序规则 比较首字母，汉字在前面,如果都是汉字则按拼音排序，其他字符也按照localcompar排序
 */
export const sortName: (preCode: string, nextCode: string) => number = (preCode: string, nextCode: string) => {
    if (chinesePattern.test(preCode) && chinesePattern.test(nextCode)) {
        return preCode.localeCompare(nextCode);
    } else if (chinesePattern.test(preCode)) {
        return -1;
    } else if (chinesePattern.test(nextCode)) {
        return 1;
    } else {
        return preCode.localeCompare(nextCode);
    }
};
