Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何对antd表中的布尔列进行排序?_Javascript_Reactjs_Antd - Fatal编程技术网

Javascript 如何对antd表中的布尔列进行排序?

Javascript 如何对antd表中的布尔列进行排序?,javascript,reactjs,antd,Javascript,Reactjs,Antd,在我的表中,其中一列是布尔值。我想对那个专栏进行排序。怎么做 sorter: (a, b) => a.isPayment.localeCompare(b.isPayment), render: (val)=><div className="text_overlap">{val ? 'Yes':'No'}</div> sorter:(a,b)=>a.isPayment.localeCompare(b.isPayment), render:(

在我的表中,其中一列是布尔值。我想对那个专栏进行排序。怎么做

sorter: (a, b) => a.isPayment.localeCompare(b.isPayment),
render: (val)=><div className="text_overlap">{val ? 'Yes':'No'}</div>
sorter:(a,b)=>a.isPayment.localeCompare(b.isPayment),
render:(val)=>{val?'Yes':'No'}
我猜
localeCompare
只适用于字符串。

在JavaScript中,我们有:

true-false==1
假-真===-1
所以你所要做的就是在你的分类器函数中减去布尔值

分拣机:(a,b)=>a-b

代码中表示的布尔列的值是多少?我假设它们只有2个值,因此localCompare工作正常。
true
false
。如果true dispaly Yes,else在列中显示No,这与语法更改
sorter:(a,b)=>a.isPayment-b.isPayment,