22052RE: [Clip] Sorting groups?
- Sep 4, 2011Two possibilities:
1 - (A mod of yours):
Replace all "^P" with "||" (unique EOL char string)
Replace all "]" with "]^P" (one line per group)
Replace all "||" with "^P"
Replace all "[" with "[^P"
2 - (Using arrays) - On 2nd thought this is too complicated
Set delimiter to "]"
Input doc/file to array
Output to file
At 09/04/2011 12:01, you wrote:
>I figured out an inelegant method to do this. For anyone that's
>interested, here's what I did.
>1. Copy the first line in each group up to the opening bracket.
>2. Replace all CR's between groups with double vertical bars, certain to
>not otherwise exist in my files.
>So, each line becomes this:
>Replace all || with CR
>Delete whatever follows [(a copy of firstline)
>Works good, but not pretty.
>From: firstname.lastname@example.org [mailto:email@example.com] On
>Behalf Of John Shotsky
>Sent: Sunday, September 04, 2011 09:28
>Subject: [Clip] Sorting groups?
>I'd like to be able to sort groups alphabetically, ascending only. The
>groups are identified with square brackets, and I
>want to sort only on the first line in each group, with the other lines in
>each group left in place.
>Here are two example groups: (Sort only on the first word in each group.)
>This should be the last group
>A lot of lines may exist within this group and they should not be changed.
>End of first group
>Beginning of second group, which should become the first group
>Lots more lines may exist in this group, and they should not be changed.
>End of second group.
>I've played around with a few ideas, but so far I'm not even close. There
>may be hundreds of such groups.
- << Previous post in topic Next post in topic >>