@swyg/sorteo
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

sorteo

👯 Easily sort an array of objects with multiple criteria.

Combine it with @swyg/memo for blazing fast performance!

⚠️ Not to be confused with the Spanish word "sorteo": https://m.interglot.com/es/en/Sorteo


Installation

npm install @swyg/sorteo

yarn install @swyg/sorteo

Usage

Functions:

  • getCompareByStringFn<T>(getValue: (x: T) => string, sortDirection: SortDirection = SortDirection.Ascending, fallback?: CompareFunction<T>): CompareFunction<T>
  • getCompareByNumberFn<T>(getValue: (x: T) => number, sortDirection: SortDirection = SortDirection.Ascending, fallback?: CompareFunction<T>): CompareFunction<T>
  • getCompareByDateFn<T>(getValue: (x: T) => Date, sortDirection: SortDirection = SortDirection.Ascending, fallback?: CompareFunction<T>): CompareFunction<T>

TODO

  • Configure how NaN, undefined, null and/or '' are handled (e.g. always at the end, always at the start, depending on order param...).

Readme

Keywords

none

Package Sidebar

Install

npm i @swyg/sorteo

Weekly Downloads

5

Version

1.0.1

License

Apache-2.0

Unpacked Size

26.7 kB

Total Files

16

Last publish

Collaborators

  • vincentropy
  • danziger
  • leafty