Skip to content

Commit c4d89c7

Browse files
committed
chore: ensure order of generated operators (for real!)
1 parent 6b79ab0 commit c4d89c7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/shared.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ export async function getOperators() {
123123
}),
124124
(el) => el.name,
125125
).sort((a, b) => {
126-
return pinyin.compare(a.name, b.name) || a.id.localeCompare(b.id, 'zh')
126+
// 默认的 pinyin.compare() 没有传入 locale 参数,导致在不同的系统上有不同的排序结果,
127+
// 所以这里手动实现一下,并带上 locale
128+
// https://github.com/MaaAssistantArknights/maa-copilot-frontend/pull/265
129+
const pinyinA = String(pinyin(a.name))
130+
const pinyinB = String(pinyin(b.name))
131+
return (
132+
pinyinA.localeCompare(pinyinB, 'zh') || a.id.localeCompare(b.id, 'en')
133+
)
127134
})
128135
return {
129136
professions,

0 commit comments

Comments
 (0)