Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:34:40+00:00 2026-05-30T20:34:40+00:00

I have an array of dates in ISO8601 format and need to sort them.

  • 0

I have an array of dates in ISO8601 format and need to sort them. Does anyone have a suggestion for an algorithm that would work? I don’t think they will sort as strings unless I’m much mistaken, so I assume they have to be broken down into their component parts?

Can someone post an algorithm, preferably language agnostic, but VB or C# example would work as long as it just uses strings and integers and no functions that are built-in to the language.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:34:41+00:00Added an answer on May 30, 2026 at 8:34 pm

    It depends on whether or not you’re mixing formats.

    Within any specific format, like yyyy-mm-dd or yyyy-Www-d, ISO 8601 is built to sort lexicographically (other than negative years).

    From the ISO 8601 wikipedia page:

    Date and time values are organised from the most to the least significant: year, month (or week), day, hour, minute, second, and fraction of second. The lexicographical order of the representation thus corresponds to chronological order, except for date representations involving negative years. This allows dates to be naturally sorted by, for example, file systems.

    That means that string sorting should work okay.

    It’s only if you mix formats will that not work. If that’s the case, you’ll need to convert to a specific format before comparing. By that, I mean something like converting all formats into yyyy-mm-dd before comparison and then back afterwards if desired.

    For example, if you have the input data:

    2010-03-01
    2010-W01-1
    

    you could first change them all to:

    2010-03-01:2010-03-01
    2010-01-04:2010-W01-1
    

    (prefixing the actual data with a specific form) then sort that. Once sorted, you then go back and strip off everything up to the first : character in each element, which will recover the original form.

    Not necessarily the most efficient way but you’ll need to do something like that if you want to preserve the original form. If that’s not an issue, simply convert them to the specific form once and leave them like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that I would like to sort using a date field
I have an Array that returns a requested series of dates that I would
I have an array of dates which are in the format 20100808 (YYYYMMD). How
I have an String array of dates in the format ex:'2010-05-04 11:26:46 +0530'. How
I have a javascript array of dates, in the form {year:'2010',month:'6',day:'23'} I need to
I have an array of dates whose format is like this: 10/15/2005 or 2/10/2011.
If you have an array of ISO dates, how would you calculate the most
I have an array that contains dates and values. An example of how it
I have an array of dates that I am populating adding the dates creating
I have an array of items that all have start and end dates associated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.