You are here: PSPad forum > English discussion forum > Re: Sort Contents By Date

Re: Sort Contents By Date

#1 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="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
2. <message date="05/11/2010 15:48:31" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
3. <message date="11/04/2011 23:31:09" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
4. <message date="08/09/2012 22:31:26" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" 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="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
2. <message date="11/04/2011 23:31:09" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
3. <message date="05/11/2010 15:48:31" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
4. <message date="09/01/2009 15:00:48" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>

How can I achieve this? I have 4700 lines of it to convert.

Thanks in advance!

Options: Reply | Quote | Up ^


#2 Re: Sort Contents By Date

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="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
2. <message date="05/11/2010 15:48:31" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
3. <message date="11/04/2011 23:31:09" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
4. <message date="08/09/2012 22:31:26" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" 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="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
2. <message date="11/04/2011 23:31:09" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
3. <message date="05/11/2010 15:48:31" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" recipient="">TEXT MESSAGE</message>
4. <message date="09/01/2009 15:00:48" sender="&quot;SENDERS NAME &quot; &lt;SENDERS NUMBER&gt;" 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

Options: Reply | Quote | Up ^






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