Skip to content

QuickSort

Since 1.4.0

QuickSort implementation at type level.

Signature

typescript
type QuickSort<T extends number[], Order extends 'asc' | 'desc' = 'asc'> = ...

Parameters

ParameterDescription
TTuple of numbers to sort
OrderSort order: 'asc' or 'desc'

Description

Type-level implementation of the QuickSort algorithm. Uses partition-based sorting with pivot selection.

Examples

Ascending Order

typescript
import type { QuickSort } from 'uni-types'

type Sorted = QuickSort<[3, 1, 4, 1, 5]>
// [1, 1, 3, 4, 5]

Descending Order

typescript
type Desc = QuickSort<[1, 2, 3], 'desc'>
// [3, 2, 1]

Released under the MIT License.