how to sort a table in alphabetical order with antd [duplicate]

旧街凉风 提交于 2021-01-21 00:44:02

问题


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,

    }]

回答1:


You can use localeCompare()

sorter: (a, b) => a.first_name.localeCompare(b.first_name);


来源:https://stackoverflow.com/questions/55808128/how-to-sort-a-table-in-alphabetical-order-with-antd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!