Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

curlysort

yashtailor6ISC1.0.0

sorting array of objects

sorting

readme

Curly-Sort

Installation

npm i curlysort

curlysort : Function takes two params

  • first parameter is an array of objects
  • second parameter is the key, if the key is not present in any element that the function will add that the element and assign null
  • type of key must String
  • if the type of the element is not an object(any of it), then it simply returns original array

example use case

arr = [
{
  x:201
},
{
  x:150
},
{
  x:170
},
{

}
]

curlysort(arr,'x')

Returns : [ { x: null }, { x: 150 }, { x: 170 }, { x: 201 } ]