Skip to content

sortDateTimes

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

Sort an array of PlainDateTime values in ascending or descending order.

  • Returns empty array if no valid datetimes.
  • Validation is performed on each item in the array.
ParameterTypeDescription
dateTimesstring[]Array of ISO PlainDateTime strings (e.g. “2024-03-10T12:00:00”)
order"asc" | "desc"“asc” for ascending (earliest first) | “desc” for descending (latest first)

Sorted array of datetime strings

import { sortDateTimes } from "@northguild/gmt/plain/calculate";
sortDateTimes(["2024-03-10T12:00:00", "2024-01-01T08:00:00", "2024-02-15T15:30:00"]) // ["2024-01-01T08:00:00", "2024-02-15T15:30:00", "2024-03-10T12:00:00"]
dateTimes
output 

plain/calculate/sortDateTimes.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.