Open this example in the interactive library
Source code
const dates = ["2026-10-22", "2025-12-01", "2026-01-02"];
console.log(dates.sort());
Sample output
[ '2025-12-01', '2026-01-02', '2026-10-22' ]

Compare date-only values. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const dates = ["2026-10-22", "2025-12-01", "2026-01-02"];
console.log(dates.sort());
[ '2025-12-01', '2026-01-02', '2026-10-22' ]