项目中目前使用的是 lodash 中提供的 orderBy,想改为直接用 javascript 实现,求最简单实现方法
通过下面的代码解决了
if (property && order) {
const compare = new Intl.Collator("zh-CN").compare;
tags = tags.sort((x, y) => compare(x[property], y[property]));
if (order === 'desc') tags = tags.reverse();
}
参考: