compare-at-paths

1.0.0 • Public • Published

compare-at-paths

create a compare function that compares given paths into an object.

example

[
  {foo: true, bar: {baz: 1}},
  {foo: true, bar: {baz: 3}},
  {foo: true, bar: {baz: 2}},
  {foo: false, bar: {baz: 1}}
].sort(Compare([['bar', 'baz'], ['foo']]))

output will be

[
  {foo: false, bar: {baz: 1}},
  {foo: true, bar: {baz: 1}},
  {foo: true, bar: {baz: 2}},
  {foo: true, bar: {baz: 3}}
]

if you want a field to be in decending order, use {$reverse: [path...]}

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    79
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    79

Package Sidebar

Install

npm i compare-at-paths

Weekly Downloads

32

Version

1.0.0

License

MIT

Unpacked Size

3.73 kB

Total Files

5

Last publish

Collaborators

  • dominictarr