# table.sortByCount 库模块帮助文档

[🅰 范例](https://www.aardio.com/zh-cn/doc/example/Windows/ListView/grid.html)

## table 成员列表 <a id="table" href="#table">&#x23;</a>

### table.sortByCount <a id="table.sortByCount" href="#table.sortByCount">&#x23;</a>
对数组或二维数组中的出现的重复元素计数并排序

### table.sortByCount(array,field,desc) <a id="table.sortByCount" href="#table.sortByCount">&#x23;</a>
- 参数 @array 指定需要排序的数组或二维数组。  
- 如果参数 @array 是二维数组，则必须用参数 @field 指定用于计数排序的字段名或数值索引。  
- 如果需要倒序，可将 @desc 参数指定为 true 。  

此函数对输入数组进行排序，并返回两个值：计数表（countMap）,排序值数组（sortedValues）。  
- sortedValues 包含了所有参考排序的元素值（去掉了重复项）。  
- countMap 则是表对象，countMap 的键就是 sortedValues 中的全部元素值，  
countMap 的值为这些元素出现在原数组中的的次数。
