Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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,

    }]
like image 494
OAH Avatar asked Apr 23 '19 09:04

OAH


People also ask

How do I sort in ANTD table?

Simply define a new sorting routine in utils/sorter. js , add it to the Sorter “enum,” and use it in your sorter prop for any column that needs it. You can check out the CodeSandbox for this tutorial to play around with the result.

How do I select rows in ANTD table?

Rows can be selectable by making first column as a selectable column. You can use rowSelection.type to set selection type. Default is checkbox . selection happens when clicking checkbox by default.


1 Answers

You can use localeCompare()

sorter: (a, b) => a.first_name.localeCompare(b.first_name);
like image 166
Maheer Ali Avatar answered Oct 19 '22 10:10

Maheer Ali