• Login
Community
  • Login

Notepad++ Sort Class

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 4 Posters 598 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.
  • J
    JediSQL
    last edited by JediSQL Jun 9, 2023, 9:57 PM Jun 9, 2023, 9:56 PM

    Hi,
    When I use “Edit > Line Operations > Sort Lines Lex. Ascending Ignoring Case” I get a different sort order than when I use PowerShell’s “Sort-Object” command.
    I have a process where we compare a list from one source with a list from another source.
    What class does Notepad++ use to implement the “Sort Lines Lex. Ascending Ignoring Case” feature?
    Maybe I can use that class in PowerShell to sort there and get the same results.

    M 1 Reply Last reply Jun 9, 2023, 10:32 PM Reply Quote 0
    • M
      Mark Olson @JediSQL
      last edited by Mark Olson Jun 9, 2023, 10:33 PM Jun 9, 2023, 10:32 PM

      @JediSQL
      I don’t know what you mean by “class”, but Notepad++ only ignores the case of ASCII characters, (e.g., treats A and a as equivalent but not Ồ and ồ (to choose two random non-ASCII letters)). Most popular case-insensitive string-sorting algorithms (including presumably PowerShell’s) ignore the case of all letters, including non-ASCII ones.

      There is already an open issue in the GitHub repo. I started working on a pull request for this issue, but I got side-tracked. I’ll try to poke the core devs again and see if I get get it moving again.

      J 2 Replies Last reply Jun 9, 2023, 11:31 PM Reply Quote 0
      • J
        JediSQL @Mark Olson
        last edited by JediSQL Jun 9, 2023, 11:31 PM Jun 9, 2023, 11:31 PM

        @Mark-Olson Thank you. My problem is not with foreign characters. Notepad++ sorts letters before underscores; PowerShell sorts letters after underscores. The two would sort these in opposite orders:
        abc, ab_

        1 Reply Last reply Reply Quote 0
        • J
          JediSQL @Mark Olson
          last edited by Jun 9, 2023, 11:34 PM

          @Mark-Olson Oh, by “class,” I assume that Notepad++ is using some .Net framework class to do the sorting.

          1 Reply Last reply Reply Quote 0
          • C
            Coises
            last edited by Jun 9, 2023, 11:38 PM

            @JediSQL said in Notepad++ Sort Class:

            What class does Notepad++ use to implement the “Sort Lines Lex. Ascending Ignoring Case” feature?

            It works its way down to this line:
            LONG lres = LCMapString(LOCALE_INVARIANT, LCMAP_UPPERCASE, &input, 1, &result, 1);
            to convert all strings to be compared to uppercase.

            J 1 Reply Last reply Jun 9, 2023, 11:55 PM Reply Quote 2
            • C
              Coises
              last edited by Jun 9, 2023, 11:47 PM

              You might be able to use the Sort Ascending (Locale) function in my Columns++ plugin. I think this is the same sort Windows uses for filenames, so it might also be the same sort you’re getting from PowerShell.

              J 1 Reply Last reply Jun 9, 2023, 11:56 PM Reply Quote 1
              • J
                JediSQL @Coises
                last edited by JediSQL Jun 9, 2023, 11:56 PM Jun 9, 2023, 11:55 PM

                @Coises Thank you. I do not think that addresses, though, the relative order of letters versus special characters. (this is a reply to your first post.)

                P 1 Reply Last reply Jun 10, 2023, 12:25 AM Reply Quote 0
                • J
                  JediSQL @Coises
                  last edited by Jun 9, 2023, 11:56 PM

                  @Coises Hmm, OK. I’ll take a look at Columns++.

                  1 Reply Last reply Reply Quote 0
                  • P
                    PeterJones @JediSQL
                    last edited by PeterJones Jun 10, 2023, 12:34 AM Jun 10, 2023, 12:25 AM

                    @JediSQL said in Notepad++ Sort Class:

                    I do not think that addresses, though, the relative order of letters versus special characters.

                    Yes it does. Uppercase come before underscore come before lowercase in lexicographic order. If Notepad++ is capitalizing all letters to sort ignoring case, then it will put letters before underscore. If PowerShell is lowercasing all letters, it will put letters after underscore.

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