sorted List

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am using a sorted List to add dates to it.
It appears that the dates aren't getting sorted.
Is it that sorted Lists cannot work with dates when it comes to sorting???


PK
 
This works for me:
SortedList sl = new SortedList();
sl.Add(DateTime.Now.AddHours(1), "4");
sl.Add(DateTime.Now.AddHours(2), "5");
sl.Add(DateTime.Now.AddHours(3), "6");
sl.Add(DateTime.Now.AddHours(-3), "1");
sl.Add(DateTime.Now.AddHours(-2), "2");
sl.Add(DateTime.Now.AddHours(-1), "3");

for (int i = 0; i < sl.Count; ++i)
{
Response.Write(sl.GetKey(i));
}

What's not working for you?

Karl
 
Hi,
I was expecting it to sort on values but l got that it sorts on keys.
Is there a way I can make it sort on values and not on keys?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top