Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sort-array

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort-array - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

11

dist/index.js

@@ -348,8 +348,9 @@ (function (global, factory) {

/**
* @param {Array} array - Input array.
* @param {object} [options] - Sort config.
* @param {Array} array - The input array to sort. It is sorted in place.
* @param {object} [options] - Config object.
* @param {string[]} [options.by] - One or more property names or computed fields to sort by. Specifying property names is only relevant when sorting an array of objects.
* @param {string[]} [options.order] - One or more sort orders. Specify `asc`, `desc` or the property name from `options.customOrders`.
* @param {object} [options.customOrders] - An object containing one or more custom orders. Each custom order must be an array defining the order expected values must be sorted in.
* @param {object} [options.computed] - An object containing one or more computed field functions.
* @param {string[]} [options.order] - One or more sort orders. Specify `asc`, `desc` or a property name from the `options.customOrders` object.
* @param {object} [options.customOrders] - A dictionary object containing one or more custom orders. Each custom order value must be an array defining the order expected values must be sorted in.
* @param {object} [options.computed] - A dictionary object containing one or more computed field functions.
* @returns {Array} Returns the array that was passed in.
* @alias module:sort-array

@@ -356,0 +357,0 @@ */

@@ -7,3 +7,3 @@ {

],
"version": "3.0.0",
"version": "3.0.1",
"description": "Isomorphic, load-anywhere function to sort an array by scalar, deep or computed values in any standard or custom order",

@@ -10,0 +10,0 @@ "repository": "https://github.com/75lb/sort-array",

@@ -26,3 +26,3 @@ [![view on npm](http://img.shields.io/npm/v/sort-array.svg)](https://www.npmjs.org/package/sort-array)

The default sort order is `asc`. You can also specify `desc` or a custom order. For example, sort parts of the day by the time in which they occur.
The default sort order is `asc`. You can also specify `desc` or the name of a property from the `customOrders` object. For example, sort the parts of the day by the time in which they occur.

@@ -39,10 +39,10 @@ ```js

Sort by a computed field. For example, an algorithm to rank boxers by influence.
Sort by a computed field, e.g. an algorithm to rank boxers by influence. Define your computed fields in the `computed` object, each value being a function which takes an array member as input and returns the value to be sorted by. In this example we sort by `rank` - the name of our computed field supplied in `computed`.
```js
> const boxers = [
{ name: 'Anthony', ticketsSold: 90000, titlesHeld: 0 },
{ name: 'Amir', ticketsSold: 30000, titlesHeld: 2 },
{ name: 'Vasiliy', ticketsSold: 20000, titlesHeld: 4 },
{ name: 'Josh', ticketsSold: 10000, titlesHeld: 3 },
{ name: 'Anthony', ticketsSold: 90000, titlesHeld: 0 }
]

@@ -71,5 +71,3 @@

{ inner: { number: 3 } },
{ inner: { number: 5 } },
{ inner: { number: 1 } },
{ inner: { number: 4 } }
{ inner: { number: 1 } }
]

@@ -86,5 +84,3 @@

{ inner: { number: 2 } },
{ inner: { number: 3 } },
{ inner: { number: 4 } },
{ inner: { number: 5 } }
{ inner: { number: 3 } }
]

@@ -140,13 +136,14 @@ ```

### sortArray(array, [options]) ⏏
### sortArray(array, [options]) ⇒ <code>Array</code> ⏏
**Kind**: Exported function
**Returns**: <code>Array</code> - Returns the array that was passed in.
| Param | Type | Description |
| --- | --- | --- |
| array | <code>Array</code> | Input array. |
| [options] | <code>object</code> | Sort config. |
| array | <code>Array</code> | The input array to sort. It is sorted in place. |
| [options] | <code>object</code> | Config object. |
| [options.by] | <code>Array.&lt;string&gt;</code> | One or more property names or computed fields to sort by. Specifying property names is only relevant when sorting an array of objects. |
| [options.order] | <code>Array.&lt;string&gt;</code> | One or more sort orders. Specify `asc`, `desc` or the property name from `options.customOrders`. |
| [options.customOrders] | <code>object</code> | An object containing one or more custom orders. Each custom order must be an array defining the order expected values must be sorted in. |
| [options.computed] | <code>object</code> | An object containing one or more computed field functions. |
| [options.order] | <code>Array.&lt;string&gt;</code> | One or more sort orders. Specify `asc`, `desc` or a property name from the `options.customOrders` object. |
| [options.customOrders] | <code>object</code> | A dictionary object containing one or more custom orders. Each custom order value must be an array defining the order expected values must be sorted in. |
| [options.computed] | <code>object</code> | A dictionary object containing one or more computed field functions. |

@@ -153,0 +150,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc