sorted-object-entries
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

sorted-object-entries

Build Status npm version Node.js Version

Sorted Object.entries in ascending or descending order.

Installation

npm i sorted-object-entries

Usage

import sortedObjEntries from 'sorted-object-entries';

const obj = {
  liu: 1,
  zhang: 2,
  wu: 3,
  li: 4,
  zhao: 5,
  qian: 6,
  ao: 7,
  xue: 8,
  bo: 9,
};

sortedObjEntries(obj);
/* [
    ['ao', 7],
    ['bo', 9],
    ['li', 4],
    ['liu', 1],
    ['qian', 6],
    ['wu', 3],
    ['xue', 8],
    ['zhang', 2],
    ['zhao', 5],
  ]
*/

sortedObjEntries(obj, { desc: true });
/* [
    ['zhao', 5],
    ['zhang', 2],
    ['xue', 8],
    ['wu', 3],
    ['qian', 6],
    ['liu', 1],
    ['li', 4],
    ['bo', 9],
    ['ao', 7],
  ]
*/

Readme

Keywords

Package Sidebar

Install

npm i sorted-object-entries

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

4.52 kB

Total Files

6

Last publish

Collaborators

  • mgenware