Community
    • Login

    Notepad++ Sort Class

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 4 Posters 599 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.
    • JediSQLJ
      JediSQL
      last edited by JediSQL

      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.

      Mark OlsonM 1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @JediSQL
        last edited by Mark Olson

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

        JediSQLJ 2 Replies Last reply Reply Quote 0
        • JediSQLJ
          JediSQL @Mark Olson
          last edited by JediSQL

          @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
          • JediSQLJ
            JediSQL @Mark Olson
            last edited by

            @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
            • CoisesC
              Coises
              last edited by

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

              JediSQLJ 1 Reply Last reply Reply Quote 2
              • CoisesC
                Coises
                last edited by

                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.

                JediSQLJ 1 Reply Last reply Reply Quote 1
                • JediSQLJ
                  JediSQL @Coises
                  last edited by JediSQL

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

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • JediSQLJ
                    JediSQL @Coises
                    last edited by

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

                    1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @JediSQL
                      last edited by PeterJones

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