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

Re: Block Sorting

Expand Messages
  • Eb
    Ray, If the sections are delimited by blank lines, a quick an durty way might be to temporarily join each table row into a single line (unwrapped), sort the
    Message 1 of 13 , Mar 2, 2011
      Ray,

      If the sections are delimited by blank lines, a quick an durty way might be to temporarily join each table row into a single line (unwrapped), sort the lines by Modify/Sort/Ascending, and unjoin again.

      Your blank lines will have been sorted to the top, delete them and reinsert blank lines with the replace menu:

      Replace
      <!-- ***
      With
      ^P<!-- ***

      No clip needed.


      Cheers.

      Eb

      --- In ntb-clips@yahoogroups.com, Ray Shapp <rayshapp@...> wrote:
      >
      > sections of the table separately. Motorcycles shouldn't be mixed in with
      > other types of vehicles.
    • Sheri
      Goofed and tried to post this reply online under a non-list member ID so I don t expect it to show up (but it might be a duplicate). You could put the rows
      Message 2 of 13 , Mar 2, 2011
        Goofed and tried to post this reply online under a non-list member ID so
        I don't expect it to show up (but it might be a duplicate).

        You could put the rows into an otl outline with sortable text on the
        header. Sort the outline, then remove the headers. Could be automated
        with regex (but a slight hiccup would need addressing in your sample
        text owing to a line break in the middle of one of the vehicle
        manufacture names -- no line breaks allowed in outline headers).

        Would it be simpler to use Excel?

        Or, maybe you could attach some javascript to the page for live sorting
        (and capture the resulting html).

        Regards,
        Sheri
      • Ray Shapp
        Hi Eb and Sheri
        Message 3 of 13 , Mar 2, 2011
          Hi Eb and Sheri


          <<a quick an durty way might be to temporarily join each table row into a
          > single line (unwrapped), sort the lines >>
          >
          > <<You could put the rows into an otl outline with sortable text on the
          > header. Sort the outline, then remove the headers. Could be automated with
          > regex (but a slight hiccup would need addressing in your sample text owing
          > to a line break in the middle of one of the vehicle manufacture name>>
          >

          Both are good ideas. I'm experimenting with them both. Since each row begins
          with the sort key in a comment, and the comments will become a permanent
          part of the document, line breaks in manufacturer name will not be a
          problem. These ideas are pretty slick because I won't need to mess with
          Access or Excel or Java scripts.

          I should have results to report tomorrow.

          Many thanks.

          Ray Shapp


          On Wed, Mar 2, 2011 at 4:50 PM, Eb <ebbtidalflats@...> wrote:

          >
          >
          > Ray,
          >
          > If the sections are delimited by blank lines, a quick an durty way might be
          > to temporarily join each table row into a single line (unwrapped), sort the
          > lines by Modify/Sort/Ascending, and unjoin again.
          >
          > Your blank lines will have been sorted to the top, delete them and reinsert
          > blank lines with the replace menu:
          >
          > Replace
          > <!-- ***
          > With
          > ^P<!-- ***
          >
          > No clip needed.
          >
          > Cheers.
          >
          > Eb
          >
          >
          > --- In ntb-clips@yahoogroups.com, Ray Shapp <rayshapp@...> wrote:
          > >
          > > sections of the table separately. Motorcycles shouldn't be mixed in with
          > > other types of vehicles.
          >
          >
          >


          [Non-text portions of this message have been removed]
        • Don
          Right that would do it -- and you don t need the line breaks anyway -- that is what wordwrap is for.
          Message 4 of 13 , Mar 2, 2011
            Right that would do it -- and you don't need the line breaks anyway --
            that is what wordwrap is for.

            > <<a quick an durty way might be to temporarily join each table row into a
            >> single line (unwrapped), sort the lines >>


            > Both are good ideas. I'm experimenting with them both.
          • Ray Shapp
            Hi Eb and Don,
            Message 5 of 13 , Mar 2, 2011
              Hi Eb and Don,

              <<Right that would do it -- and you don't need the line breaks anyway --
              > that is what wordwrap is for.>>
              >

              Problem solved! The join/sort/split works perfectly. Done entirely within
              NoteTab, and no clip required.

              Thanks to all who responded - Axel, Don, Eb, Sheri. (Did you notice that you
              folks replied in alphabetical order?)

              Ray Shapp


              On Wed, Mar 2, 2011 at 7:51 PM, Don <don@...> wrote:

              >
              >
              > Right that would do it -- and you don't need the line breaks anyway --
              > that is what wordwrap is for.
              >
              >
              > > <<a quick an durty way might be to temporarily join each table row into a
              > >> single line (unwrapped), sort the lines >>
              >
              > > Both are good ideas. I'm experimenting with them both.
              >
              >


              [Non-text portions of this message have been removed]
            • Eb
              Yes, Microsoft s latest invention, the cloud queue. Each PC delays its posts until its turn. Except for Axel s. Germans are renowned for the ability to get
              Message 6 of 13 , Mar 3, 2011
                Yes,

                Microsoft's latest invention, the "cloud" queue. Each PC delays its posts until its turn. Except for Axel's. Germans are renowned for the ability to get to the head of the Q. (;-) The German National Motto, "Ich drängel doch nich!" is heard at every train, bus, and theater door.

                Just kidding Axel.

                Prost.

                PS
                actually, there might be a grain of truth to this motto. Back in the early 1920's the German Gubmint issued new money so fast, that people were getting paid twice a day, and rushed right to the store to spend it, as it would lose value so fast, that in the morning you might be able to buy a loaf of bread, and by lunch time, you would be lucky to get a slice from that loaf for the same money.

                Before the off-topic police cranks their recliner forward, lets make this a clip:

                H="Calculate Daily Inflation"
                ^!Set %lunchtimeprice%=^?[Enter price at lunchtime]
                ^!Set %breakfastprice%=^?[Enter price at breakfast]
                ^!Set %inflation%=^$Calc(100*(^%lunchtimeprice%/^%breakfastprice%-1))$
                ^!Info [L]Today's inflation was ^%inflation% percent.

                Eb

                --- In ntb-clips@yahoogroups.com, Ray Shapp <rayshapp@...> wrote:
                > ...

                > Thanks to all who responded - Axel, Don, Eb, Sheri. (Did you notice that you
                > folks replied in alphabetical order?)
                >
              • Art Kocsis
                Hi Ray, Short answer: Do now. Long answer: Other posters have already beat me to the punch to use the join/split commands to solve your problem. I use that
                Message 7 of 13 , Mar 6, 2011
                  Hi Ray,

                  Short answer: Do now.

                  Long answer:

                  Other posters have already beat me to the punch to use the join/split
                  commands to solve your problem. I use that technique quite frequently.

                  Since I like to keep my original formatting, I add a unique temporary
                  character (such as %, &, #, etc) to the end of each non-empty line before
                  executing the join command and put two of these characters at the end
                  of the last line in each group. After sorting, the original formatting is
                  easily
                  restored by simply replacing each temporary character with a CRLF. This
                  also restores the empty line between groups.

                  Although it is pretty simple to do manually, a clip makes it even simpler so
                  why not dash off a quick clip? Answer: there is no such thing as a quick clip!

                  Not wanting to publish a clip that was not robust and did not handle abnormal
                  conditions, I ran into three problems:
                  - Multiple separator lines
                  - Oddities of high-bit characters
                  - Real life demands on my time

                  RegEx to the rescue for the first problem!

                  The second problem comes from wanting to use a temp character that would
                  have a very low probability of appearing in the document and a difference in
                  "mindset" between me and Notetab. To me high-bit characters such as thorn
                  (alt 0254) are special characters similar to &, #, etc but to Notetab they are
                  regular characters, i.e., they are word characters. So it is not a bug in
                  NT after
                  all that it can find a @ in @@ but cannot find a þ in þþ without the T option!

                  The third problem is self explanatory.

                  Interestingly, it turns out that I had written a clip to do this very thing
                  over two
                  years ago and forgot about it. I was pleased to see that I have made a bit of
                  progress in my coding, especially in the use of RegEx.

                  To the curious, I avoid "GoTos" unless absolutely necessary as it makes for
                  much more readable and error-free code.
                  ##################### Code follows: ###################
                  Sort Groups

                  ;Clip to sort (ascending), groups of lines of text, each group
                  ; consisting of one or more lines with each line terminated by an
                  ; EOL, and each group of lines separated by one or more blank lines
                  ;
                  ;Note: This clip will affect either preselected text only
                  ; or the entire document if no text is preselected
                  ;Note: the temporary character "þ" (Thorn, ANSI 254 = ALT 0254),
                  ; must not occur at any place in the selected text.
                  ;Note: "þ" is a word character, hence requires the "T" ^!Find option
                  ; #, @, $, %, etc are non-word chars & do not require the T option
                  ;Note: If you want to keep the group spacing for all groups, make sure
                  ; you include the CRLF on the last line

                  ;Rev History
                  ;03-06-11 Created Clip

                  ^!StatusShow Running Group Sort
                  ^!SetScreenUpdate Off
                  ;^!SetDebug On

                  ^!Set %SlctSz%=^$GetSelSize$
                  ^!If ^%SlctSz%=0 ^!Jump Doc_Start
                  ^!Find "þ" HST

                  ^!IfError Safe
                  ^!Continue Error: Text to be sorted contains internal test character "þ",
                  exiting clip
                  ^!Goto End

                  :Safe
                  ^!If ^%SlctSz%>0 ^!Replace "^P" >> "þ" AISTH
                  ^!If ^%SlctSz%>0 ^!Replace "þ{2,}" >> "þ\r\n" AIRSTH
                  ^!If ^%SlctSz%=0 ^!Replace "^P" >> "þ" AISTW
                  ^!If ^%SlctSz%=0 ^!Replace "þ{2,}" >> "þ\r\n" AIRSTW
                  ^!Toolbar Sort Ascending
                  ^!Replace "þ" >> "^P" AISTH
                  ^!If ^%SlctSz%=0 ^!Jump Doc_Start

                  ^!Continue Align Left or Cancel?
                  ^!Toolbar Left Align

                  ^!SetDebug Off
                  ##################### Code complete ##################

                  Namaste', Art

                  At 03/02/2011 11:26, Ray wrote:
                  >To All,
                  >
                  >My question: Do we have any clips in the Fookes libraries that would sort
                  >multi-line blocks of text based on a unique key sequence such as I have
                  >described?
                • Ray Shapp
                  Hello Art, That s a major piece of work. I ll definitely use it. Many thanks! Ray Shapp ... [Non-text portions of this message have been removed]
                  Message 8 of 13 , Mar 7, 2011
                    Hello Art,

                    That's a major piece of work. I'll definitely use it.

                    Many thanks!

                    Ray Shapp


                    On Sun, Mar 6, 2011 at 2:55 PM, Art Kocsis <artkns@...> wrote:

                    >
                    >
                    > Hi Ray,
                    >
                    > Short answer: Do now.
                    >
                    > Long answer:
                    >
                    > Other posters have already beat me to the punch to use the join/split
                    > commands to solve your problem. I use that technique quite frequently.
                    >
                    > Since I like to keep my original formatting, I add a unique temporary
                    > character (such as %, &, #, etc) to the end of each non-empty line before
                    > executing the join command and put two of these characters at the end
                    > of the last line in each group. After sorting, the original formatting is
                    > easily
                    > restored by simply replacing each temporary character with a CRLF. This
                    > also restores the empty line between groups.
                    >
                    > Although it is pretty simple to do manually, a clip makes it even simpler
                    > so
                    > why not dash off a quick clip? Answer: there is no such thing as a quick
                    > clip!
                    >
                    > Not wanting to publish a clip that was not robust and did not handle
                    > abnormal
                    > conditions, I ran into three problems:
                    > - Multiple separator lines
                    > - Oddities of high-bit characters
                    > - Real life demands on my time
                    >
                    > RegEx to the rescue for the first problem!
                    >
                    > The second problem comes from wanting to use a temp character that would
                    > have a very low probability of appearing in the document and a difference
                    > in
                    > "mindset" between me and Notetab. To me high-bit characters such as thorn
                    > (alt 0254) are special characters similar to &, #, etc but to Notetab they
                    > are
                    > regular characters, i.e., they are word characters. So it is not a bug in
                    > NT after
                    > all that it can find a @ in @@ but cannot find a � in �� without the T
                    > option!
                    >
                    > The third problem is self explanatory.
                    >
                    > Interestingly, it turns out that I had written a clip to do this very thing
                    >
                    > over two
                    > years ago and forgot about it. I was pleased to see that I have made a bit
                    > of
                    > progress in my coding, especially in the use of RegEx.
                    >
                    > To the curious, I avoid "GoTos" unless absolutely necessary as it makes for
                    > much more readable and error-free code.
                    > ##################### Code follows: ###################
                    > Sort Groups
                    >
                    > ;Clip to sort (ascending), groups of lines of text, each group
                    > ; consisting of one or more lines with each line terminated by an
                    > ; EOL, and each group of lines separated by one or more blank lines
                    > ;
                    > ;Note: This clip will affect either preselected text only
                    > ; or the entire document if no text is preselected
                    > ;Note: the temporary character "�" (Thorn, ANSI 254 = ALT 0254),
                    > ; must not occur at any place in the selected text.
                    > ;Note: "�" is a word character, hence requires the "T" ^!Find option
                    > ; #, @, $, %, etc are non-word chars & do not require the T option
                    > ;Note: If you want to keep the group spacing for all groups, make sure
                    > ; you include the CRLF on the last line
                    >
                    > ;Rev History
                    > ;03-06-11 Created Clip
                    >
                    > ^!StatusShow Running Group Sort
                    > ^!SetScreenUpdate Off
                    > ;^!SetDebug On
                    >
                    > ^!Set %SlctSz%=^$GetSelSize$
                    > ^!If ^%SlctSz%=0 ^!Jump Doc_Start
                    > ^!Find "�" HST
                    >
                    > ^!IfError Safe
                    > ^!Continue Error: Text to be sorted contains internal test character "�",
                    > exiting clip
                    > ^!Goto End
                    >
                    > :Safe
                    > ^!If ^%SlctSz%>0 ^!Replace "^P" >> "�" AISTH
                    > ^!If ^%SlctSz%>0 ^!Replace "�{2,}" >> "�\r\n" AIRSTH
                    > ^!If ^%SlctSz%=0 ^!Replace "^P" >> "�" AISTW
                    > ^!If ^%SlctSz%=0 ^!Replace "�{2,}" >> "�\r\n" AIRSTW
                    > ^!Toolbar Sort Ascending
                    > ^!Replace "�" >> "^P" AISTH
                    > ^!If ^%SlctSz%=0 ^!Jump Doc_Start
                    >
                    > ^!Continue Align Left or Cancel?
                    > ^!Toolbar Left Align
                    >
                    > ^!SetDebug Off
                    > ##################### Code complete ##################
                    >
                    > Namaste', Art
                    >
                    > At 03/02/2011 11:26, Ray wrote:
                    > >To All,
                    >
                    > >
                    > >My question: Do we have any clips in the Fookes libraries that would sort
                    > >multi-line blocks of text based on a unique key sequence such as I have
                    > >described?
                    >
                    >
                    >


                    [Non-text portions of this message have been removed]
                  Your message has been successfully submitted and would be delivered to recipients shortly.