Community
    • Login

    Sort case insensitive on 64 bit?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    sortcase insensitiv64-bit
    17 Posts 6 Posters 1.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • EkopalypseE
      Ekopalypse @Corey-Keller
      last edited by

      @Corey-Keller

      checkout menu edit->line operations.

      1 Reply Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Corey-Keller
        last edited by

        @Corey-Keller

        sorry, I missed the insensitive part.
        No, there is no builtin function other then converting the lines prior to sorting it.

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Ekopalypse
          last edited by

          @Ekopalypse

          I wonder why there isn’t a case insensitive sort?
          It seems only a slight step beyond a normal sort.
          Any idea?

          EkopalypseE 1 Reply Last reply Reply Quote 1
          • EkopalypseE
            Ekopalypse @Alan Kilborn
            last edited by

            @Alan-Kilborn

            Sorry, I don’t know.
            Maybe it’s just a “my day has 24 hours only too” problem.

            1 Reply Last reply Reply Quote 2
            • Corey-KellerC
              Corey-Keller
              last edited by

              @Alan-Kilborn and @Ekopalypse I’m not surprised that it’s not a native function. What surprises me is that no one has made a plugin for something that I’d think would be quite common.

              EkopalypseE 1 Reply Last reply Reply Quote 1
              • EkopalypseE
                Ekopalypse @Corey-Keller
                last edited by

                @Corey-Keller

                well, there is, more or less a plugin which can do it.
                It’s called pythonscript. If you want to go this way, then
                I can provide a script which should do what you want.

                1 Reply Last reply Reply Quote 0
                • Corey-KellerC
                  Corey-Keller
                  last edited by

                  @Ekopalypse that would be helpful! Thank you!

                  I may try and relearn c++ (it’s been about a decade) and see if I can write a proper one at some point though.

                  EkopalypseE 1 Reply Last reply Reply Quote 0
                  • EkopalypseE
                    Ekopalypse @Corey-Keller
                    last edited by

                    @Corey-Keller

                    after you installed pythonscript plugin from Plugin Admin,
                    click on new script in the plugin menu. Give it a meaningful name
                    and put this line into it.

                    editor.setText('\r\n'.join(sorted(editor.getText().splitlines(), key=str.lower)))
                    

                    Save it. Done.

                    To run it, go to plugins->pythonscript->scripts->your_script

                    1 Reply Last reply Reply Quote 3
                    • Terry RT
                      Terry R
                      last edited by Terry R

                      @Corey-Keller said in Sort case insensitive on 64 bit?:

                      Is there any way to sort lines case insensitively on 64 bit Notepad++?

                      I believe another way is possible without using pythonscript (or other external plugins) etc. However it will mean the file will grow to twice the size initially before it shrinks again.

                      I’m suggesting using a regex to copy the entire line, and paste another “capitalised” version of it in front, followed by a number of special characters so it can easily be removed later in the process.

                      So the Replace function would be
                      Find What:(?-s)^(.+)$
                      Replace With:\U\1\E ## \1
                      Use the "Replace All button with wraparound also pre-selected.

                      So this captures each line, it then replaces the line with first a capitalised version, followed by a space, two hashes and another space and then the original line. Note I’ve used the hash #, but any other combination will work. Just bear in mind some characters such as @*$^*! have special meanings, so you may need to play with the combinations.

                      At this point perform a normal lexicographical sort. Then we’d need to remove the first portion by using the following Replace regex.
                      Find what:(?-s)(.+? ## )
                      Replace With: nothing in this field

                      You now have it sorted as if every character was capitalised.

                      Terry

                      1 Reply Last reply Reply Quote 2
                      • Terry RT
                        Terry R
                        last edited by

                        After supplying the answer in the previous post I realised it might be possible to combine all these steps into a macro, thus creating a “one-click” wonder. OK, well actually 2 clicks.

                        So if you feel up to the challenge you can edit a file called shortcuts.xml. Depending on how your Notepad++ is running it might be in one of several locations. in my case I open a File Explorer window, then type %appdata% in the top location field and press enter. At this point it should open a folder showing several other folders, you want the Notepad++ folder, shortcuts.xml is contained within.

                        This file can be edited within Notepad++, however (and very important) make this the ONLY file you edit in a Notepad++ session. If unsure, then close and re-open Notepad++ before opening this file.

                        The lines below can be inserted within this file (at the appropriate line) and then the file can be saved and closed. Exit Notepad++ again and re-open and you should now have the Macro entry (under Macro in top menu) “Upper-sort”. This macro combines all the steps my previous post alluded to.

                        You might want to change the name and the special characters I used " ## " before inserting the following lines into shortcuts.xml, feel free to do so.

                        Good luck
                        Terry

                               <Macro name="Upper-sort" Ctrl="no" Alt="no" Shift="no" Key="0">
                                    <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                    <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s)^(.+)$" />
                                    <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                    <Action type="3" message="1602" wParam="0" lParam="0" sParam="\U\1\E ## \1" />
                                    <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
                                    <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                                    <Action type="2" message="0" wParam="42059" lParam="0" sParam="" />
                                    <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                                    <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s)^(.+? ## )" />
                                    <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                                    <Action type="3" message="1602" wParam="0" lParam="0" sParam="" />
                                    <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
                                    <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                                </Macro>
                        
                        Alan KilbornA 1 Reply Last reply Reply Quote 3
                        • guy038G
                          guy038
                          last edited by

                          Hello, @corey-keller, @ekopalypse, @alan-kilborn, @terry-r and All,

                          Ah… yes, Terry, useful macro, indeed !

                          Two other possible regex syntaxes for the S/R, before sort :

                          SEARCH (?-s)^.+

                          REPLACE \U$0\E##$0

                          OR

                          SEARCH ^(?=(.+))

                          REPLACE \U\1##

                          Note that I did not add space characters before and after the ## string


                          For people whose their language has accentuated characters, look that post, too :

                          https://community.notepad-plus-plus.org/post/55362

                          Best Regards

                          guy038

                          1 Reply Last reply Reply Quote 2
                          • Alan KilbornA
                            Alan Kilborn @Terry R
                            last edited by

                            @Terry-R

                            Nice one, Terry!
                            One suggestion, though: Why not name the macro to “Sort Ignoring Case”?

                            1 Reply Last reply Reply Quote 0
                            • guy038G
                              guy038
                              last edited by

                              Hi @alan-kilborn, @terry-r and All,

                              or, may be : Letter caseless sort ?

                              BR

                              guy038

                              1 Reply Last reply Reply Quote 0
                              • Terry RT
                                Terry R
                                last edited by

                                Hi @guy038 @Alan-Kilborn @Corey-Keller
                                I had to come up with a quick name. I’m certainly not going to stop anyone creating a better one. Actually in the meantime I think I may have a better name although it is a bit long winded. Its:
                                Caseless Ranked Ascending Patterning
                                or
                                C.R.A.P. for short.

                                Terry

                                Michael VincentM 1 Reply Last reply Reply Quote 1
                                • Michael VincentM
                                  Michael Vincent @Terry R
                                  last edited by

                                  @Terry-R said in Sort case insensitive on 64 bit?:

                                  C.R.A.P. for short.

                                  I may sue for copyleft infringement :-)

                                  CRAPPS (Cisco Router Action Performing Perl Script)

                                  Seriously, it’s a thing (the CRAPPS that is, not the suing for copyleft infringement)

                                  Cheers.

                                  Alan KilbornA 1 Reply Last reply Reply Quote 2
                                  • Alan KilbornA
                                    Alan Kilborn @Michael Vincent
                                    last edited by

                                    @Michael-Vincent @Terry-R

                                    Hey! Those don’t should like sh!tty names!
                                    They seem like backronyms to me though. :-)

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post
                                    The Community of users of the Notepad++ text editor.
                                    Powered by NodeBB | Contributors