sortUnix
Signature
Section titled “Signature”sortUnix(unixValues: number[], order?: "asc" | "desc"): number[]import { sortUnix } from "@northguild/gmt/unix/calculate";Sort an array of Unix timestamp values in ascending or descending order.
- Filters invalid values before sorting.
- Supports “asc” (earliest first) or “desc” (latest first).
- Returns [] if array is empty or has no valid values.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
unixValues |
number[] |
Array of Unix timestamps (e.g. 1699531200) |
order |
"asc" | "desc" |
“asc” for ascending (earliest first) | “desc” for descending (latest first) |
Returns
Section titled “Returns”Sorted array of Unix timestamps
Examples
Section titled “Examples”sortUnix([1706659200000, 1704067200000, 1700000000000]) // [1700000000000, 1704067200000, 1706659200000]sortUnix([1704067200, 1700000000], "desc") // [1704067200, 1700000000]sortUnix([]) // []