Skip to content

sortUtc

  • The core functions, which every industry uses.
sortUtc(utcDateTimes: string[], order?: "asc" | "desc"): string[]

Sort an array of UTC datetime 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.
ParameterTypeDescription
utcDateTimesstring[]Array of ISO datetime strings (e.g. “2024-03-10T12:00:00Z”)
order"asc" | "desc"“asc” for ascending (earliest first) | “desc” for descending (latest first)

Sorted array of UTC datetime strings

import { sortUtc } from "@northguild/gmt/utc/calculate";
sortUtc(["2024-03-12T12:00:00Z", "2024-03-10T12:00:00Z", "2024-03-15T12:00:00Z"]) // ["2024-03-10T12:00:00Z", "2024-03-12T12:00:00Z", "2024-03-15T12:00:00Z"]
utcDateTimes
output 

utc/calculate/sortUtc.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.