| User: editor -- 2011-07-27 << 825 827 >> |
| Hits: 222 |
| 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 |