$ npm install length-sort
Sort an array of strings by length
$ npm install length-sort
const lengthSort = require('length-sort');
['ab', 'a', 1234, 'abc'].sort(lengthSort.asc);
//=> ['a', 'ab', 'abc', 1234]
['ab', 'a', 1234, 'abc'].sort(lengthSort.desc);
//=> [1234, 'abc', 'ab', 'a']
Ascending sort.
Descending sort.
MIT © Kevin Mårtensson
© 2010 - cnpmjs.org x YWFE | Home | YWFE