472,985 Members | 3,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 software developers and data experts.

Sorting the file Name

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

sample01192005.log

sample01202004.log

sample01202005.log

ample012020051517.log

sample012020051522.log

So the general format of files are <file_name>ddmmyyyyhhmm .
Where hhmm are optional .
Now those file names I put into a list and calling sort() command .
sort obviously will not sort in the form of date .

Can anyone help me to implement sort function .

Thanks,
AB
Jul 22 '05 #1
1 2270
Abhijit Bhadra wrote:

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

sample01192005.log

sample01202004.log

sample01202005.log

ample012020051517.log

sample012020051522.log

So the general format of files are <file_name>ddmmyyyyhhmm .
Where hhmm are optional .
Now those file names I put into a list and calling sort() command .
sort obviously will not sort in the form of date .

Can anyone help me to implement sort function .
You made yourself a lot of troubles by choosing a hard to parse
format for including the time stamp into the file name. If
possible change that first

eg. sample012020052004.log

is that file sample.log created at the day = 01
month = 20
year = 2005
hour = 20
minute = 04
or is that file
sample0120.log created at the day = 20
month = 05
year = 2004

In any case. Every sort algorithm needs to compare 2 entries,
to decide which one is less.
In your case this means: locate the date/time stamp, extract
that and base your comparison on that instead of the full
filename.

So your first goal is: to locate and extract the time/date stamp.
Once you have that and you still have problems inserting that
information into a sorting algorithm, come back and ask for
help again. But for this, you definitly need the date/time stamp
alone.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2

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

Similar topics

4
by: James P | last post by:
Hi All, I have an xml file as listed below. This is a list of scripts. Some of the scripts depend on the output of other scripts. I want to sort this xml in such a way that the scripts are...
20
by: Xah Lee | last post by:
Sort a List Xah Lee, 200510 In this page, we show how to sort a list in Python & Perl and also discuss some math of sort. To sort a list in Python, use the “sort” method. For example: ...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
25
by: Dan Stromberg | last post by:
Hi folks. Python appears to have a good sort method, but when sorting array elements that are very large, and hence have very expensive compares, is there some sort of already-available sort...
5
by: Cindy Lee | last post by:
I'm getting my data from an XML file. The data binds fine, but I can't sort on it. Do I have to do anything special? I have enabled sorting on my grid view. Autogenerate columns is off, and I...
5
by: ^cypis^ vel. SQ9JTI | last post by:
Hi there, i have a problem. I prepared bucket sorting with reading values from file (data.txt) and saving to other file (aus.txt). Everything is good if we talk about reading and sorting, but...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
3
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article...
5
by: saran3b2 | last post by:
Hi all, If u know the solution please suggest me. I need these urgent. production.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="xsl/vinoth-new.xsl"?>...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.