Loading ...
Sorry, an error occurred while loading the content.

22052RE: [Clip] Sorting groups?

Expand Messages
  • Art Kocsis
    Sep 4, 2011
      Two possibilities:
      1 - (A mod of yours):
      Replace all "^P" with "||" (unique EOL char string)
      Replace all "]" with "]^P" (one line per group)
      Select all
      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
      Sort 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:
      >[firstline||firstline again||rest||of||the||lines]
      >Sort ascending.
      >Replace all || with CR
      >Delete whatever follows [(a copy of firstline)
      >Works good, but not pretty.
      >-----Original Message-----
      >From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On
      >Behalf Of John Shotsky
      >Sent: Sunday, September 04, 2011 09:28
      >To: ntb-clips@yahoogroups.com
      >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.
      >More lines.
      >More lines.
      >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.
      >More lines.
      >More lines.
      >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.
      >Any ideas?
    • Show all 9 messages in this topic