【文件属性】:
文件名称:sort-indexes:
文件大小:135KB
文件格式:ZIP
更新时间:2021-04-11 13:38:06
JavaScript
排序索引
对数组的元素进行排序,并以排序的顺序返回一个新数组,其中包含原始数组中的索引。
用法
sortIndexes ( array [ , comparator ] )
参数
array的数组进行排序。
comparator (可选),用于定义排序顺序。
返回值
一个新数组,其中包含按排序顺序排列的array的索引。
例子
import sortIndexes from 'sort-indexes' ;
sortIndexes ( [ 'foo' , 'bar' , 'oxo' ] ) ;
// returns [1, 0, 2]
sortIndexes ( [ 5 , 1 , 3 , 4 , 2 ] , ( a , b ) => b - a ) ;
// returns [0, 3, 2, 4, 1]
【文件预览】:
sort-indexes-master
----.babelrc(60B)
----rollup.config.js(272B)
----.lintstagedrc(35B)
----package.json(1KB)
----.prettierrc(26B)
----.prettierignore(26B)
----LICENSE(1KB)
----package-lock.json(645KB)
----src()
--------index.js(311B)
--------__tests__()
----.huskyrc(53B)
----.gitignore(26B)
----CHANGELOG.md(782B)
----README.md(576B)