Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

826.Text sort -- How to sort all the lines by the order of date with format day-month-year?

User: editor -- 2011-07-27          << 825  827 >>
Hits: 2140
Type: Text sort   
Search all Text sort examples
Description:
How to sort all the lines by the order of date with format day-month-year?
There are several column in text file, the 5th column is date with format of D-M-YYYY, how to sort by this column?
Input Sample:
A1 A2 A3 A4 26-3-2009 A6
B1 B2 B3 B4 7-11-2001 B6
C1 C2 C3 C4 12-9-2001 C6
D1 D2 D3 D4 10-10-2008 D6
Output Sample:
C1 C2 C3 C4 12-9-2001 C6
B1 B2 B3 B4 7-11-2001 B6
D1 D2 D3 D4 10-10-2008 D6
A1 A2 A3 A4 26-3-2009 A6
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open the text file
2. ctrl-h open 'replace' dialog
* set 'replace with pattern' to:

* click 'advanced' tab, set 'run following at the beginning of replace' to:

3. click 'replace', done!

Note: function 'mysort' will extract the date column, and  reformat the date to YYYY-MM-DD: 2001-09-12, function sort_by_func($match,'mysort') will sort all lines according to the return value of function 'mysort'

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to sort numbers by the order of distance from some number? (63%)
How to sort all the lines of a text file by order the multiple columns? (62%)
How to sort all the lines of a text file randomly? (60%)
How to sort all lines of ip addresses in a text file? (59%)
How to sort a list of email addresses by the order of the domain name? (58%)
How to sort the lines in a text files by the order of line length? (56%)
How to convert all the phrases to the Abbr automatically? (55%)
How to extract all specified date format from a text file? (54%)

Check Demo of Text sort
Keywords:
ddd  chm  321  5th  year  several  month  yyyy  sort all lines  200  extract by column  several lines  return tab  lines function  extract value  order lines text file  extract column  sort lines of text