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 7569583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:12:09+00:00 2026-05-30T15:12:09+00:00

I am setting up a list of date times: DateTime a1 DateTime a2 DateTime

  • 0

I am setting up a list of date times:

DateTime a1
DateTime a2
DateTime a3
DateTime a4

The above looks like this (as DateTime objects):

3/1/2012 10:56
3/1/2012 17:03
3/1/2012 1:38
3/1/2012 5:33

Then I put them in a list and sort:

List<DateTime> ldtBites = new List<DateTime>();
ldtBites.Add(a1);
ldtBites.Add(a2);
ldtBites.Add(a3);
ldtBites.Add(a4);
ldtBites.Sort();

After Sorting I get this:

3/1/2012 1:38:00 AM
3/1/2012 10:56 AM
3/1/2012 5:03:00 PM
3/1/2012 5:33:00 AM
  • 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-30T15:12:10+00:00Added an answer on May 30, 2026 at 3:12 pm

    You omitted the definition of w,x,y,z. I defined them as such:

    DateTime w = new DateTime(2012, 3, 1, 10, 56, 0);
    DateTime x = new DateTime(2012, 3, 1, 17, 3, 0);
    DateTime y = new DateTime(2012, 3, 1, 1, 38, 0);
    DateTime z = new DateTime(2012, 2, 29, 17, 3, 0);
    

    This causes them to match your values for a1-a4; however, when I run the rest of your code, they sort correctly (a3, a4, a1, a2).

    However, I noticed that x and z were the same hour/minute, so my initial test had this:

    DateTime z = new DateTime(2012, 3, 1, 17, 3, 0);
    

    When I ran this, I got them to come out in the order you were showing (a3, a1, a2, a4); however, after the AddHours() call went through, the z value was actually 3/2/2012, which is why it was last.

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

Sidebar

Related Questions

I am setting-up my DataGridView like this: jobs = new List<DisplayJob>(); uxJobList.AutoGenerateColumns = false;
I've been having some issues setting up a list of items and moving them
I know this looks like a lot of text, but I think it's a
How to enumerate items of Spark List component after setting dataProvider property? I mean
Anyone know where i can find a list of the columns for setting the
I have this page, let's call it index.php index.php has a list of users
I have 2 selects for setting the expiration date on a credit card and
So I'm binding a list of custom business objects to a Rad chart, for
Disclaimer: This might be a duplicate of datetime vs. timestamp? , but I feel
I have a list collection like below : using System; using System.Collections.Generic; using System.Linq;

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.