You are here: PSPad forum > English discussion forum > Re: Sort Contents By Date
Posted by: Digistras | Date: 2013-08-25 12:16 | IP: IP Logged
Hi guys,
I have the following example of XML data:
1. <message date="09/01/2009 15:00:48" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
2. <message date="05/11/2010 15:48:31" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
3. <message date="11/04/2011 23:31:09" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
4. <message date="08/09/2012 22:31:26" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
Currently, the "message date" are sorted in ascending order. I need to invert the message date order so that the 2012 is at the top and follows descending downwards to become like this:
1. <message date="08/09/2012 22:31:26" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
2. <message date="11/04/2011 23:31:09" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
3. <message date="05/11/2010 15:48:31" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
4. <message date="09/01/2009 15:00:48" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
How can I achieve this? I have 4700 lines of it to convert.
Thanks in advance!
Posted by: vbr | Date: 2013-08-25 14:42 | IP: IP Logged
Digistras:Hi guys,I have the following example of XML data:
1. <message date="09/01/2009 15:00:48" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
2. <message date="05/11/2010 15:48:31" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
3. <message date="11/04/2011 23:31:09" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
4. <message date="08/09/2012 22:31:26" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>Currently, the "message date" are sorted in ascending order. I need to invert the message date order so that the 2012 is at the top and follows descending downwards to become like this:
1. <message date="08/09/2012 22:31:26" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
2. <message date="11/04/2011 23:31:09" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
3. <message date="05/11/2010 15:48:31" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>
4. <message date="09/01/2009 15:00:48" sender=""SENDERS NAME " <SENDERS NUMBER>" recipient="">TEXT MESSAGE</message>How can I achieve this? I have 4700 lines of it to convert.
Thanks in advance!
Hi,
it would be probably more appropriate to manipulate the XML data with some xml parser and rebuilt the listing with the needed sort method, but it might be possible in the text editor too, if there aren't some irregularities.
I'd convert the dates to year/month/day to allow meaningful alphabetic sorting
replace using regular expression:
<message date="(\d\d)/(\d\d)/(\d\d\d\d)
with:
<message date="$3/$2/$1
(let's hope, there are hours data with starting zero, if appropriate, such as 03, 09 ... - otherwise the sorting might be broken here.)
Edit :: Sort:
Direction
(o) Descending
Advanced
[x] Specify column
Column begin: 15
Column end: 35
hth,
vbr
Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR