sort-object-value
v1.0.3
Published
🎀 0 dependency values based object keys sorting.
Downloads
2
Maintainers
Readme
sort-object-value
🎀 0 dependency values based object keys sorting.
- immutable
- small footprint
- 0 learning curve
- 0 dependency
- tested
Installation
npm i sort-object-value
Usage
import objSort from 'sort-object-value'
const obj = {
md: 768,
dm: -768.965,
sm: 576.28367,
ms: -576,
xs: 0,
xl: 1200.23872,
lx: -1200,
lg: 992,
gl: -992.34632,
}
ascending sort
const ascending = objSort(obj)
console.log(ascending)
// output
// {
// lx: -1200,
// gl: -992.34632,
// dm: -768.965,
// ms: -576,
// xs: 0,
// sm: 576.28367,
// md: 768,
// lg: 992,
// xl: 1200.23872,
// }
descending sort
const descending = objSort(obj,true)
console.log(descending)
// output
// {
// xl: 1200.23872,
// lg: 992,
// md: 768,
// sm: 576.28367,
// xs: 0,
// ms: -576,
// dm: -768.965,
// gl: -992.34632,
// lx: -1200,
// }