Deduplicate comparator logic in sortNumEngZhtw
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RaRBJFZKSTA7naHGuQHfnQ
This commit is contained in:
@@ -16,17 +16,7 @@
|
|||||||
* @returns {Array<string|number>} The sorted array (same reference).
|
* @returns {Array<string|number>} The sorted array (same reference).
|
||||||
*/
|
*/
|
||||||
export function sortNumEngZhtw(data) {
|
export function sortNumEngZhtw(data) {
|
||||||
return data.sort((a, b) => {
|
return data.sort(sortNumEngZhtwForFilter);
|
||||||
const isANumber = !Number.isNaN(Number.parseFloat(a)) && Number.isFinite(Number(a));
|
|
||||||
const isBNumber = !Number.isNaN(Number.parseFloat(b)) && Number.isFinite(Number(b));
|
|
||||||
|
|
||||||
if (isANumber && isBNumber) return Number.parseFloat(a) - Number.parseFloat(b);
|
|
||||||
|
|
||||||
if (isANumber) return -1;
|
|
||||||
if (isBNumber) return 1;
|
|
||||||
|
|
||||||
return a.localeCompare(b, "zh-Hant-TW", { sensitivity: "accent" });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user