Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

988.Text sort -- How to sort paragraphs base on the second word in each paragraph?

User: Chris -- 2012-08-10          << 987  989 >>
Hits: 1892
Type: Text sort   
Search all Text sort examples
Description:
How to sort paragraphs base on the second word in each paragraph?

How sort the following example text, based on the second word in each paragraph. Each paragraph has multiple lines and it is defined by a distinct word. The first three lines of the file need to be excluded.
Input Sample:
Do not move this line #1
Do not move this line #2
Do not move this line #3
Paragraph cad xxxx xxx xxx xxx xx
Xxx xx xx xxx xxx 
Xxx xx xx  
Paragraph abc xx xxx xxx xxxx xx
Xxx xxx xx xxxx xxx  
Paragraph bac xxx  xxxx xxx
Xxx
Xxx
Xxx
(Note: because the procedure below use "_" as line delimiter, we require no "_" is appeared in the source file)
Output Sample:
Do not move this line #1
Do not move this line #2
Do not move this line #3
Paragraph abc xx xxx xxx xxxx xx
Xxx xxx xx xxxx xxx  
Paragraph bac xxx  xxxx xxx
Xxx
Xxx
Xxx
Paragraph cad xxxx xxx xxx xxx xx
Xxx xx xx xxx xxx 
Xxx xx xx  
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Proc:
A. remove and record the first 3 lines
B. change each paragraph to a single line:
Paragraph cad .._<line2>_<line3>...
Paragraph abc .._<line2>_...
...
C. sort lines
D. restore multiple lines and restore first 3 lines

A:
1. ctrl-o open text file
2. ctrl-h open 'replace' dialog
* set 'replace with pattern' to:

* in 'advanced' tab, set 'run following for each matched unit' to:

3. click 'replace'

B:
4. ctrl-h open 'replace' dialog
* set 'replace unit' to "Paragraph"
* set 'replace with pattern' to:

* in 'settings' tab, set 'Para Start' to "other":

5. click 'replace'

C:
6. ctrl-h open 'replace' dialogue and set 'replace with pattern' to:

7. click 'replace'

D:
8. ctrl-h open 'replace' dialog
* set 'replace with pattern':

9. click replace.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Screenshot 3:  Replace_Window


Screenshot 4:  Replace_Settings_Window


Screenshot 5:  Replace_Window


Screenshot 6:  Replace_Window


Similar Examples:
How to add a <hr> at the end of each paragraph? (60%)
How to sort many lines by comparing the second word in each line? (60%)
How to randomly select one line from each paragraph? (58%)
How to exchange the 1st and 2nd lines in each paragraph? (58%)
How to sort paragraphs according to order of first date? (56%)
How to sort the text by the number of specific word in each line? (55%)
How to separate each paragraph by two lines? (53%)
How to insert a word or phrase to the begining of each line? (52%)

Check Demo of Text sort
Keywords:
sort paragraphs  restore  first three  sort paragraph  paragraphs  based on  record  sort lines  abc  define  sort by second word in paragraph word  record text example  second paragraph  paragraph defined  remove paragraphs  the first word sort  sort text by second word in word  remove paragraph