473,699 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting a list by DateTime stamp -- please help...

Hi,
I have a list object called "myList" with the first item a string and
the second a DateTime. Something like this:

"some text 1", 19/03/2008 12:56:36
"some text 2", 19/03/2008 10:56:36
"some text 3", 19/03/2008 11:56:36
"some text 4", 19/03/2008 13:56:36
I would like to sort "myList" (into a new list) by timestamp such
that the earliest time stamp is a tthe bottom. In this case it would
be:

"some text 2", 19/03/2008 10:56:36

Problem is though I don't know how to do this exactly! Would
appreciate any comments/suggestions/code-samples that you would liek
to share.

Thanking you,
Al.
Mar 19 '08 #1
1 2540

You would be very well served to read:
http://ludwig-stuyck.spaces.l ive.com/Blog/cns!E36D9BA98FC 913B3!398.entry

the article on Generics.

It is in english.

...

Find the Sort section.

...

You can write the comparer "inline" (previous post on this thread) ... or
you can actually code up the the Comparer.

...

<al*****@altavi sta.comwrote in message
news:1e******** *************** ***********@e60 g2000hsh.google groups.com...
Hi,
I have a list object called "myList" with the first item a string and
the second a DateTime. Something like this:

"some text 1", 19/03/2008 12:56:36
"some text 2", 19/03/2008 10:56:36
"some text 3", 19/03/2008 11:56:36
"some text 4", 19/03/2008 13:56:36
I would like to sort "myList" (into a new list) by timestamp such
that the earliest time stamp is a tthe bottom. In this case it would
be:

"some text 2", 19/03/2008 10:56:36

Problem is though I don't know how to do this exactly! Would
appreciate any comments/suggestions/code-samples that you would liek
to share.

Thanking you,
Al.

Mar 19 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3722
by: Koen | last post by:
Hi! I have a vector containing the following: vector<Base*> theVector; theVector.push_back(new Der1()); theVector.push_back(new Der1()); theVector.push_back(new Der2()); theVector.push_back(new Der2()); ....
12
2381
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that field... This grid displayes results based on users search.. public static int numberDiv; private void Page_Load(object sender, System.EventArgs e) {
1
2306
by: Abhijit Bhadra | last post by:
Hi , In C++ , I have some files as per their date of creation . The files are in the form of maple01012005.log maple01142005.log maple01202005.log sample01182005.log
2
3752
by: Samuel | last post by:
Hello, I am trying to convert a local time into UTC ISO8601, then parse it back into local time. I tried the following: ---------------------- #!/usr/bin/python import time import datetime import xml.utils.iso8601
0
2627
by: Prasad More | last post by:
I want to open a TIFF file, put a datetime stamp on it and save that file in CompressionCCITT4 format back to the same filename. I have written following code to do this, but getting "Invalid parameter used. at System.Drawing.Image.Save(String filename, ImageCodeInfo encoder, EncoderParameters encoderParams)" error. public void EditTIFFImage(string strImageFile) { EncoderParameters encParamsCompress = new EncoderParameters(1);
19
25459
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to sort columns based on the column header the user has clicked in both Ascending and Descending formats.
7
2188
by: apotheos | last post by:
I can't seem to get this nailed down and I thought I'd toss it out there as, by gosh, its got to be something simple I'm missing. I have two different database tables of events that use different schemas. I am using python to collate these records for display. I do this by creating a list of lists that look roughly like this: events = , ...] I then thought I'd just go events.sort(lambda x,y: x<y) and call
4
7691
by: JB | last post by:
I am trying to get a list of all the active computers running on my domain. I'm writing some remote management style software with WMI, which works fine when i know the computer name, but i just want to be able to produce a list and work it from there. I found the following method: String path = "WinNT://MY.DOMAIN.COM"; String username = "administrator";
4
1850
by: rajtalent | last post by:
hi all, I want to sort the colum when clicks the columnheader using vb.net 2005 .But i receive the following error "Error 1 Overload resolution failed because no accessible 'New' accepts this number of arguments. " and my code is Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick If e.Column <> sortColumn Then sortColumn = e.Column...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9054
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7781
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.