• Login
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.
  • C
    Corey-Keller
    last edited by Jul 7, 2020, 7:59 PM

    @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.

    E 1 Reply Last reply Jul 7, 2020, 8:06 PM Reply Quote 0
    • E
      Ekopalypse @Corey-Keller
      last edited by Jul 7, 2020, 8:06 PM

      @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
      • T
        Terry R
        last edited by Terry R Jul 7, 2020, 8:25 PM Jul 7, 2020, 8:24 PM

        @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
        • T
          Terry R
          last edited by Jul 7, 2020, 11:44 PM

          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>
          
          A 1 Reply Last reply Jul 8, 2020, 12:56 PM Reply Quote 3
          • G
            guy038
            last edited by Jul 8, 2020, 2:07 AM

            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
            • A
              Alan Kilborn @Terry R
              last edited by Jul 8, 2020, 12:56 PM

              @Terry-R

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

              1 Reply Last reply Reply Quote 0
              • G
                guy038
                last edited by Jul 8, 2020, 2:07 PM

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

                or, may be : Letter caseless sort ?

                BR

                guy038

                1 Reply Last reply Reply Quote 0
                • T
                  Terry R
                  last edited by Jul 8, 2020, 7:45 PM

                  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

                  M 1 Reply Last reply Jul 8, 2020, 8:36 PM Reply Quote 1
                  • M
                    Michael Vincent @Terry R
                    last edited by Jul 8, 2020, 8:36 PM

                    @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.

                    A 1 Reply Last reply Jul 8, 2020, 9:06 PM Reply Quote 2
                    • A
                      Alan Kilborn @Michael Vincent
                      last edited by Jul 8, 2020, 9:06 PM

                      @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
                      17 out of 17
                      • First post
                        17/17
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors