Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
compare-property
Advanced tools
This module contains functions that can be used with Array.prototype.sort
.
npm install compare-property
var compare = require('compare-property');
[2, 1, 3].sort(compare.ascending) // [1, 2, 3]
Sort in ascending order.
[2, 1, 3].sort(compare.ascending) // [1, 2, 3]
Sort in descending order.
[2, 1, 3].sort(compare.descending) // [3, 2, 1]
Sort in case insensitive ascending order.
['a', 'B', 'c'].sort(compare.ascendingIgnoreCase) // ['a', 'B', 'c']
Sort in case insensitive descending order.
['a', 'B', 'c'].sort(compare.descendingIgnoreCase) // ['c', 'B', 'a']
Create function that sorts on a property. Specify sort order as 1 (ascending) or -1 (descending), default is ascending.
Arguments
var fn = compare.property('length', -1);
['ab', 'a', 'abc'].sort(fn) // ['abc', 'ab', 'a']
Create function that sorts on multiple properties. Specify sort order as 1 (ascending) or -1 (descending), default is ascending.
Arguments
var fn = compare.properties({ age: -1, name: 1 }, ['name']);
people.sort(fn);
// The people array will now be sorted on age from oldest to youngest.
// People with the same age will be sorted on name from A to Z ignoring case.
FAQs
Array sort compare util
The npm package compare-property receives a total of 578 weekly downloads. As such, compare-property popularity was classified as not popular.
We found that compare-property demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.