# @types/sort-array

> TypeScript definitions for sort-array

Latest version **4.1.2** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/sort-array
pnpm add @types/sort-array
yarn add @types/sort-array
bun add @types/sort-array
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.1.2 |
| Published | 2023-11-07 |
| First published | 2017-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/sort-array
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sort-array
- npm.io page: https://npm.io/package/@types/sort-array

## Recent versions

- 4.1.2 (latest) — 2023-11-07
- 4.1.0 (ts4.4) — 2021-12-30
- 2.0.0 (ts2.2) — 2017-11-14
- 4.1.1 — 2023-10-18

## README

# Installation
> `npm install --save @types/sort-array`

# Summary
This package contains type definitions for sort-array (https://github.com/75lb/sort-array#readme).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sort-array.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sort-array/index.d.ts)
````ts
type Primitive = number | string | boolean | bigint | symbol | null | undefined;
interface SortOptions<Computed> {
    /**
     * One or more property names or computed fields to sort by.
     * Specifying property names is only relevant when sorting an array of
     * objects.
     */
    by?: string | string[];
    /**
     * One or more sort orders. Specify 'asc', 'desc' or a property name from
     * the options.customOrders object.
     */
    order?: string | string[];
    /**
     * 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.
     */
    customOrders?: {
        [key: string]: any;
    };
    /**
     * A dictionary object containing one or more computed field functions. The
     * function will be invoked once per item in the array. Each invocation
     * will receive the array item as input and must return a primitive value
     * by which the array can be sorted.
     */
    computed?: {
        [key: string]: (item: Computed) => Primitive;
    };
    /**
     * Configures whether null values will be sorted before or after defined
     * values. Set to -1 for before, 1 for after. Defaults to 1.
     * @default 1
     */
    nullRank?: -1 | 1;
    /**
     * Configures whether undefined values will be sorted before or after
     * defined values. Set to -1 for before, 1 for after. Defaults to 1.
     * @default 1
     */
    undefinedRank?: -1 | 1;
}

/**
 * Isomorphic, load-anywhere function to sort an array by scalar, deep or
 * computed values in any standard or custom order. Returns the array
 * passed in.
 * @param array The input array to sort. It is sorted in place.
 * @param options Sort options.
 */
declare function sortArray<T>(array: T[], options?: SortOptions<T>): T[];
export = sortArray;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 15:11:36 GMT
 * Dependencies: none

# Credits
These definitions were written by [mrmlnc](https://github.com/mrmlnc).

---
_Source: https://npm.io/package/@types/sort-array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
