JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 587871
  • Score
    100M100P100Q171963F

Sort the keys in an object.

Package Exports

  • sort-object

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sort-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sort-object NPM version

Sort the keys in an object.

Install

Install with npm

npm i sort-object --save

Usage

var sortObj = require('sort-object');

Sort the keys on an object

console.log(sortObj({a: 1, c: 2, b: 3}));
//=> {a: 1, b: 3, c: 2}

Create a new object with only the given keys.

var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
console.log(sortObj(o, {keys: ['a', 'b']}));

//=> {a: 1, b: 3}

Sort the keys using a custom function.

var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
var obj = sortObj(o, {fn: function (a, b) {
  return a < b ? -1 : 1;
}});
console.log(obj);
//=> {a: 1, b: 3, c: 2, d: 4, e: 5}

Author

Brian Woodward

License

Copyright (c) 2014 Brian Woodward, contributors.
Released under the MIT license


This file was generated by verb-cli on August 15, 2014.