473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2292
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.