如何使用 antd 按字母顺序对表格进行排序 [英] how to sort a table in alphabetical order with antd
本文介绍了如何使用 antd 按字母顺序对表格进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按字母顺序过滤列这是按大小过滤的代码怎么做谢谢
I want to filter the column in alphabetical order here is the code to filter by the size how to do thank you
const columns = [{
title: 'First Name',
dataIndex: 'first_name',
sortDirections: ['descend', 'ascend'],
key: 'first_name',
width: '20%',
sorter: (a, b) => a.first_name.length - b.first_name.length,
}]
推荐答案
您可以使用 localeCompare()
sorter: (a, b) => a.first_name.localeCompare(b.first_name);
这篇关于如何使用 antd 按字母顺序对表格进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文