1.0.3 ā€¢ Published 4 years ago

sort-object-value v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

sort-object-value

npm GitHub PRs Welcome tylim88

šŸŽ€ 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,
// }
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-beta.0

4 years ago