const columns = [
{
title: '汉字',
dataIndex: 'name',
sorter:(a,b) => a.name.localeCompare(b.name)
},
{
title: '数字',
dataIndex: 'amount',
sorter: (a, b) => Number(a.amount) - Number(b.amount),
},
{
title: '字符串',
dataIndex: 'value',
sorter: (a, b) => a.value.localeCompare(b.value)
},
{
title: '字符串',
dataIndex: 'pbom',
sorter: (a, b) => {
for (let i = 0; i < a.pbom.length; i++) {
if (b.pbom[i] !== undefined) {
if (a.pbom.charCodeAt(i) > b.pbom.charCodeAt(i)) {
return 1;
} else {
return -1;
}
} else {
return -1;
}
}
}
}
];
String.prototype.localeCompare(),链接MDN链接
Srting.charCodeAt(index) 对比相同位置字符的值。