sort-keys-length

Sort objecy keys by length

Usage no npm install needed!

<script type="module">
  import sortKeysLength from 'https://cdn.skypack.dev/sort-keys-length';
</script>

README

sort-keys-length Build Status

Sort object keys by length

Install

$ npm install sort-keys-length

Usage

const sortKeysLength = require('sort-keys-length');

sortKeysLength.asc({ab: 'x', a: 'y', abc: 'z'});
//=> {a: 'y', ab: 'x', abc: 'z'}

sortKeysLength.desc({ab: 'x', a: 'y', abc: 'z'});
//=> {abc: 'z', ab: 'x', a: 'y'}

API

sortKeysLength.asc(object, [options])

Ascending sort.

sortKeysLength.desc(object, [options])

Descending sort.

object

Type: Object

Object to sort.

options

Type: Object

deep

Type: boolean
Default: false

Recursively sort keys.

License

MIT © Kevin Mårtensson