Nocturnal Programmer's Machine

sort-values

1.0.1 • Public • Published

Sort Values

Last version Build Status Dependency status Dev Dependencies Status NPM Status Donate

Sort the keys of an object based in the value.

Install

npm install sort-values --save

If you want to use in the browser (powered by Browserify):

bower install sort-values --save

and later link in your HTML:

<script src="bower_components/sort-values/dist/sort-values.js"></script>

Usage

var sortValues = require('sort-values');
 
sortValues({en: 10, es: 100, it: 50}, 'desc');
//=> {es: 100, it: 50, en: 10}
 
sortValues({en: 10, es: 100, it: 50}, 'asc');
//=> {en: 10, it: 50, es: 100}
 
sortValues({en: 10, es: 100, it: 50});
//=> {en: 10, it: 50, es: 100}

API

sortValues(input, mode)

input

Required Type: Object

mode

Type: String Default: asc

How to sort the object. Could be asc or desc.

Related

License

MIT © Kiko Beats

install

npm i sort-values

Downloadsweekly downloads

3

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability