https://github.com/lamansky/longest-first
[Node.js] Sorts items in descending order of length.
https://github.com/lamansky/longest-first
Last synced: 3 months ago
JSON representation
[Node.js] Sorts items in descending order of length.
- Host: GitHub
- URL: https://github.com/lamansky/longest-first
- Owner: lamansky
- License: mit
- Created: 2018-02-03T19:30:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-03T19:33:12.000Z (over 8 years ago)
- Last Synced: 2025-06-04T21:43:19.829Z (about 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# longest-first
Sorts items in descending order of length.
## Installation
Requires [Node.js](https://nodejs.org/) 6.0.0 or above.
```bash
npm i longest-first
```
## API
The module exports a single function.
* **Parameter**: `items` (iterable): Values that should be sorted by their `length` property. (The original iterable is not modified.)
* **Return Value**: Array
## Example
```javascript
const longestFirst = require('longest-first')
longestFirst(['one', 'two', 'three']) // ['three', 'one', 'two']
// Supports the bind operator
['test', 'example']::longestFirst() // ['example', 'test']
```