473,770 Members | 4,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.l og

maple01142005.l og

maple01202005.l og

sample01182005. log

sample01192005. log

sample01202004. log

sample01202005. log

ample0120200515 17.log

sample012020051 522.log

So the general format of files are <file_name>ddmm yyyyhhmm .
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 2312
Abhijit Bhadra wrote:

Hi ,
In C++ , I have some files as per their date of creation .
The files are in the form of
maple01012005.l og

maple01142005.l og

maple01202005.l og

sample01182005. log

sample01192005. log

sample01202004. log

sample01202005. log

ample0120200515 17.log

sample012020051 522.log

So the general format of files are <file_name>ddmm yyyyhhmm .
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. sample012020052 004.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
293
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 listed in the correct order of execution. I created an IComparer class and implememted the Compare method. I am calling Array.Sort on an XmlNode array. The sorting is not correct. Can anyone suggest a correct algorithm for a compare method to sort this...
20
4078
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: li=;
0
3240
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 way... here is my code on how I did it to help anyone starting out get an idea of how to use virtual mode in ..NET 2.0 Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared
25
2232
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 function that will merge like elements into a chain, so that they won't have to be recompared as many times? Thanks!
5
5976
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 use bound fields. The sort expression is just the same datafield that binds the column, but when I try to sort with the post back, nothing works.
5
1763
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 saving doesn't work. data.txt looks: 4 3 67 15
7
4827
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 expandable row, the hidden row is made visible with css. The problem is when i sort the rows, the hidden rows get sorted as well which i don't want and want to be moved (while sorting) relative to their parent rows. The following is my complete html code...
3
7346
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 uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
5
1582
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"?> <report> <production>
5
4956
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 there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html Here is some jquery js that I think...
0
10237
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9882
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
8905
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 projectplanning, coding, testing, and deploymentwithout 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
7431
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
6690
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
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
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.