Skip to content

sortDates

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

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

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

Sorted array of date strings

import { sortDates } from "@northguild/gmt/plain/calculate";
sortDates(["2024-03-10", "2024-01-01", "2024-02-15"]) // ["2024-01-01", "2024-02-15", "2024-03-10"]
dates
output 

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