Community
    • Login

    Sort Lines Lexicographically did not work

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    61 Posts 20 Posters 22.0k 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.
    • Douglas KaynorD
      Douglas Kaynor
      last edited by

      I tried sorting with no line selected, all lines selected and a couple of other variations. No luck either way.

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

        You will have to give more details of what you’re doing, because NPP v7.5.8 32-bit lexicographically sorts just fine for me.

        See this animation for what I do:

        (recorded using ScreenToGif; image uploaded to imugr; image embedding syntax: ![](https://i.imgur.com/FnvdjHz.gif))

        1 Reply Last reply Reply Quote 2
        • Scott SumnerS
          Scott Sumner
          last edited by

          @Douglas-Kaynor said:

          I can provide the list of names if needed.

          Might be time to cough up at least some of those names…

          Best to indent the lines with 4 spaces before copying and pasting here. Then they will look like this when you preview and thus also when you submit:

          I'm indented with 4 spaces
          Me too!
          Meeee three!
          
          1 Reply Last reply Reply Quote 1
          • Douglas KaynorD
            Douglas Kaynor
            last edited by

            Here is the list of lines. Notice that at line 184 things are not sorted even though I ran the sort lines lexicographically before pasting the list into the page. Also there are duplicates that should be next to each other but are not. DOS sort works just fine. Is it possible that the length of the list is to long?

            Notepad++ v7.5.8 (32-bit)
            Build time : Jul 23 2018 - 02:03:53
            Path : C:\Program Files (x86)\Notepad++\notepad++.exe
            Admin mode : OFF
            Local Conf mode : OFF
            OS : Windows 10 (64-bit)
            Plugins : ComparePlugin.dll CustomizeToolbar.dll docMonitor.unicode.dll Explorer.dll HexEditor.dll PluginManager.dll TakeNotes.dll XMLTools.dll DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll

            Aaliyah
            Abigail
            Adam
            Addison
            Adolphe
            Aidenv
            Aisha
            Alberta
            Alexander
            Alexandra
            Alexis
            Ali
            Alice
            Alyssa
            Amelia
            Andrew
            Angus
            Anna
            Annabelle
            Anthony
            Archer
            Archie
            Aria
            Ariana
            Arlo
            Ashton
            Athena
            Atlas
            Atticus
            Audrey
            Aurora
            Austin
            Ava
            Ayla
            Beau
            Beazer
            Bella
            Benjamin
            Bertha
            Betty
            Biggest
            Bill
            Billie
            BiscuitBarrel
            Blake
            Blythe
            Bodhi
            Boop
            Bottom
            Bottomfeeder
            Braxton
            Brody
            Bush
            Butt
            Caesar
            Caleb
            Campbell
            Carter
            Carway
            Cecilia
            Charles
            Charlie
            Charlotte
            Chase
            Chelsea
            Chloe
            Christian
            Christianson
            Claire
            Coioton
            Colt
            Connor
            Constantine
            Cooper
            Crabby
            Daisy
            Dan
            Daniel
            David
            Deangelo
            Delilah
            Diana
            Dominic
            Donald
            Dork
            Doug
            Douglas
            Dracula
            Dylan
            Eden
            Edward
            Eleanor
            Eli
            Elijah
            Eliza
            Elizabeth
            Ella
            Ellie
            Eloise
            Elsie
            Emilia
            Emily
            Emma
            Ethan
            Eva
            Eve
            Evelyn
            Evie
            Fanny
            Fearn
            Felix
            Finn
            Owen
            Paige
            Patrick
            Penelope
            Pepper
            Phoebe
            Piper
            Poppy
            Prudence
            Quince
            Rebecca
            Riley
            Rory
            Rose
            Ross
            RossGerm
            Ruby
            Ryan
            Ryder
            Samuel
            Sarah
            Savannah
            Scarlett
            Sebastian
            Services
            Sienna
            Smith
            Sofia
            Sophia
            Sophie
            SpongeBob
            SquidWorth
            Stella
            Stephan
            Steven
            Summer
            Super
            Tarquin
            Teresa
            Theodore
            Thomas
            Thurman
            Toby
            Trump
            Tyler
            Ulysis
            VanHelsing
            Venus
            Victor
            Victoria
            Violet
            Wagering
            Waterton
            WelshHuggins
            WhoCares
            Wigglebottom
            Wiggleworth
            William
            Willow
            Wilson
            Winifred
            Winter
            Wolfeschlegels
            Xavier
            Xenophon
            Yetty
            Zachary
            Zappa
            Zara
            Zeno
            Zevon
            Zoe
            Flynn
            Frankenstein
            Frankie
            Franklin
            Gabriel
            Gabriella
            George
            Georgia
            Germbag
            Gertrude
            Grace
            Hamish
            Hannah
            Harley
            Harlow
            Harper
            Harriet
            Harrison
            Harry
            Harvey
            Hayden
            Hazel
            Headbanger
            Henry
            Hernandez
            Holly
            Hudson
            Hugo
            Hunter
            Hypatia
            Hyxxeljksser
            Imma
            Imogen
            Indiana
            Inez
            Isaac
            Isabel
            Isabella
            Isabelle
            Isla
            Ivy
            Jack
            Jackson
            Jacob
            Jake
            James
            Jane
            Jasmine
            Jason
            Jasper
            Jaxon
            Jayden
            Jesse
            Jessica
            Jim
            John
            Jonathan
            Jones
            Jordan
            Joseph
            Joshua
            Juniper
            Kai
            Kate
            Kauror
            Kirk
            Krieper
            Lachlan
            Lara
            Layla
            Leah
            Leo
            Leon
            Lethbridge
            Levi
            Liam
            Lillian
            Lilly
            Lily
            Lincoln
            Logan
            Lola
            Louis
            Louise
            Luca
            Lucas
            Lucy
            Luke
            Mackenzie
            Maddison
            Madeleine
            Madeline
            Madison
            Magnum
            Marcus
            Martin
            Maryam
            Mason
            Matilda
            Matt
            Matthew
            Maud
            Max
            Maxwell
            Maya
            Meyer
            Mia
            Michael
            Mila
            Molly
            Muhammad
            Nate
            Nathan
            Nathaniel
            Nero
            Nicholas
            Nick
            Noah
            Nora
            OBrien
            Olive
            Oliver
            Olivia
            Ophelia
            Oscar
            Owen
            Paige
            Patrick
            Penelope
            Pepper
            Phoebe
            Piper
            Poppy
            Prudence
            Quince
            Rebecca
            Riley
            Rory
            Rose
            Ross
            RossGerm
            Ruby
            Ryan
            Ryder
            Samuel
            Sarah
            Savannah
            Scarlett
            Sebastian
            Services
            Sienna
            Smith
            Sofia
            Sophia
            Sophie
            SpongeBob
            SquidWorth
            Stella
            Stephan
            Steven
            Summer
            Super
            Tarquin
            Teresa
            Theodore
            Thomas
            Thurman
            Toby
            Trump
            Tyler
            Ulysis
            VanHelsing
            Venus
            Victor
            Victoria
            Violet
            Wagering
            Waterton
            WelshHuggins
            WhoCares
            Wigglebottom
            Wiggleworth
            William
            Willow
            Wilson
            Winifred
            Winter
            Wolfeschlegels
            Xavier
            Xenophon
            Yetty
            Zachary
            Zappa
            Zara
            Zeno
            Zevon
            Zoe

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

              It works for me.

              Notepad++ v7.5.8 (32-bit)
              Build time : Jul 23 2018 - 02:03:53
              Path : C:\Program Files (x86)\Notepad++\notepad++.exe
              Admin mode : OFF
              Local Conf mode : OFF
              OS : Windows 10 (64-bit)
              Plugins : ComparePlugin.dll dbgpPlugin.dll NppExec.dll NppFTP.dll NppTextFX.dll PluginManager.dll PreviewHTML.dll PythonScript.dll DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll

              If I copy the data you posted, create a new file, paste, and do Edit > Line Operations > Sort Lines Lexicographically Ascending, it sorts. The results are:

              Aaliyah
              Abigail
              Adam
              Addison
              Adolphe
              Aidenv
              Aisha
              Alberta
              Alexander
              Alexandra
              Alexis
              Ali
              Alice
              Alyssa
              Amelia
              Andrew
              Angus
              Anna
              Annabelle
              Anthony
              Archer
              Archie
              Aria
              Ariana
              Arlo
              Ashton
              Athena
              Atlas
              Atticus
              Audrey
              Aurora
              Austin
              Ava
              Ayla
              Beau
              Beazer
              Bella
              Benjamin
              Bertha
              Betty
              Biggest
              Bill
              Billie
              BiscuitBarrel
              Blake
              Blythe
              Bodhi
              Boop
              Bottom
              Bottomfeeder
              Braxton
              Brody
              Bush
              Butt
              Caesar
              Caleb
              Campbell
              Carter
              Carway
              Cecilia
              Charles
              Charlie
              Charlotte
              Chase
              Chelsea
              Chloe
              Christian
              Christianson
              Claire
              Coioton
              Colt
              Connor
              Constantine
              Cooper
              Crabby
              Daisy
              Dan
              Daniel
              David
              Deangelo
              Delilah
              Diana
              Dominic
              Donald
              Dork
              Doug
              Douglas
              Dracula
              Dylan
              Eden
              Edward
              Eleanor
              Eli
              Elijah
              Eliza
              Elizabeth
              Ella
              Ellie
              Eloise
              Elsie
              Emilia
              Emily
              Emma
              Ethan
              Eva
              Eve
              Evelyn
              Evie
              Fanny
              Fearn
              Felix
              Finn
              Flynn
              Frankenstein
              Frankie
              Franklin
              Gabriel
              Gabriella
              George
              Georgia
              Germbag
              Gertrude
              Grace
              Hamish
              Hannah
              Harley
              Harlow
              Harper
              Harriet
              Harrison
              Harry
              Harvey
              Hayden
              Hazel
              Headbanger
              Henry
              Hernandez
              Holly
              Hudson
              Hugo
              Hunter
              Hypatia
              Hyxxeljksser
              Imma
              Imogen
              Indiana
              Inez
              Isaac
              Isabel
              Isabella
              Isabelle
              Isla
              Ivy
              Jack
              Jackson
              Jacob
              Jake
              James
              Jane
              Jasmine
              Jason
              Jasper
              Jaxon
              Jayden
              Jesse
              Jessica
              Jim
              John
              Jonathan
              Jones
              Jordan
              Joseph
              Joshua
              Juniper
              Kai
              Kate
              Kauror
              Kirk
              Krieper
              Lachlan
              Lara
              Layla
              Leah
              Leo
              Leon
              Lethbridge
              Levi
              Liam
              Lillian
              Lilly
              Lily
              Lincoln
              Logan
              Lola
              Louis
              Louise
              Luca
              Lucas
              Lucy
              Luke
              Mackenzie
              Maddison
              Madeleine
              Madeline
              Madison
              Magnum
              Marcus
              Martin
              Maryam
              Mason
              Matilda
              Matt
              Matthew
              Maud
              Max
              Maxwell
              Maya
              Meyer
              Mia
              Michael
              Mila
              Molly
              Muhammad
              Nate
              Nathan
              Nathaniel
              Nero
              Nicholas
              Nick
              Noah
              Nora
              OBrien
              Olive
              Oliver
              Olivia
              Ophelia
              Oscar
              Owen
              Owen
              Paige
              Paige
              Patrick
              Patrick
              Penelope
              Penelope
              Pepper
              Pepper
              Phoebe
              Phoebe
              Piper
              Piper
              Poppy
              Poppy
              Prudence
              Prudence
              Quince
              Quince
              Rebecca
              Rebecca
              Riley
              Riley
              Rory
              Rory
              Rose
              Rose
              Ross
              Ross
              RossGerm
              RossGerm
              Ruby
              Ruby
              Ryan
              Ryan
              Ryder
              Ryder
              Samuel
              Samuel
              Sarah
              Sarah
              Savannah
              Savannah
              Scarlett
              Scarlett
              Sebastian
              Sebastian
              Services
              Services
              Sienna
              Sienna
              Smith
              Smith
              Sofia
              Sofia
              Sophia
              Sophia
              Sophie
              Sophie
              SpongeBob
              SpongeBob
              SquidWorth
              SquidWorth
              Stella
              Stella
              Stephan
              Stephan
              Steven
              Steven
              Summer
              Summer
              Super
              Super
              Tarquin
              Tarquin
              Teresa
              Teresa
              Theodore
              Theodore
              Thomas
              Thomas
              Thurman
              Thurman
              Toby
              Toby
              Trump
              Trump
              Tyler
              Tyler
              Ulysis
              Ulysis
              VanHelsing
              VanHelsing
              Venus
              Venus
              Victor
              Victor
              Victoria
              Victoria
              Violet
              Violet
              Wagering
              Wagering
              Waterton
              Waterton
              WelshHuggins
              WelshHuggins
              WhoCares
              WhoCares
              Wigglebottom
              Wigglebottom
              Wiggleworth
              Wiggleworth
              William
              William
              Willow
              Willow
              Wilson
              Wilson
              Winifred
              Winifred
              Winter
              Winter
              Wolfeschlegels
              Wolfeschlegels
              Xavier
              Xavier
              Xenophon
              Xenophon
              Yetty
              Yetty
              Zachary
              Zachary
              Zappa
              Zappa
              Zara
              Zara
              Zeno
              Zeno
              Zevon
              Zevon
              Zoe
              Zoe
              

              There’s nothing about your data that would cause it to not sort. There’s nothing about the Notepad++ v7.5.8 32-bit executable that would cause it not to sort. Either one of your plugins is interfering (try again, but use notepad++.exe -noPlugin when running, instead of your normal shortcut – you can even edit your normal shortcut to include that option; I just tried, and it still sorted just fine for me), or there is user error.

              Did you try the short list, like I showed in my screen capture movie? Does that work for you, or not?

              1 Reply Last reply Reply Quote 2
              • Dreamspace PresidentD
                Dreamspace President
                last edited by

                Just had the same problem. In MY case, the reason was: The file was protected from changes (was opened from TMP folder). I could not type anything.

                Once I had saved it as a new file on the desktop, I could type, and thus sorting also worked.

                1 Reply Last reply Reply Quote 3
                • r lR
                  r l
                  last edited by

                  It seems that in Notepadd++ 7.7.1 there needs to be at least one empty line after the last line of text, otherwise the sorting function doesn’t do anything.

                  If end of file is in an empty line after the last line of text, sorting works:
                  text
                  text
                  <EOF>

                  If end of file is at the end of the last line of text, sorting doesn’t work:
                  text
                  text<EOF>

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

                    @r-l said:

                    in Notepadd++ 7.7.1 there needs to be at least one empty line after the last line of text, otherwise the sorting function doesn’t do anything

                    This is NOT true when I try it. Can you provide anything more to help reproduce?

                    1 Reply Last reply Reply Quote 0
                    • r lR
                      r l
                      last edited by

                      You’re right. And I just realized what my mistake was.

                      I had searched and replaced certain character sequences prior to sorting, to insert linebreaks. In Notepad++ that linebreak must be “\r\n” rather than just “\n”. With correct linebreaks, sorting works fine. With just “\n”, the sorting function sees the whole file as one single line. Likewise, when I add an empty line at the end of the file, it only sorts that empty line to the beginning of the file but doesn’t change the sequency of anything else.

                      So, sorry for the noise… :-)

                      Alan KilbornA 1 Reply Last reply Reply Quote 3
                      • Alan KilbornA
                        Alan Kilborn @r l
                        last edited by

                        @r-l said:

                        In Notepad++ that linebreak must be “\r\n” rather than just “\n”

                        Only if you want it to be. There are Windows files (\r\n) and there are Linux (\n) files when it comes to “line endings”. If you are doing regular expression replacements, you absolutely need to be careful about using \r\n versus using \n. There is nothing there to protect you from yourself.

                        And…sorting is known to have problems when you have mixed line-endings in the data, something you shouldn’t allow to happen unless you really know what you are doing, and really need that situation.

                        1 Reply Last reply Reply Quote 4
                        • Bill HeplerB
                          Bill Hepler
                          last edited by

                          I often have problems sorting text in NotePaid++ - I’m set as Windows CR/LF etc. The problem seems to arise if spaces and tabs are interspersed as beginning of line characters…

                          Here is an example:

                          BuildAccount()            // Summary of Posted Transactions
                          BuildAudAcct()            // Tax Records that relate to Account Records....
                          BuildAudit()              // Daily & Account
                          BuildBankRec()
                          BuildCheque()
                          BuildContainer()
                          BuildCounterIDs()  // Apr 2020
                          BuildDepot( )
                          BuildEvents( )    // Dec 2019
                          BuildFinBat()
                          BuildGrower()
                          BuildImpBat()
                          BuildPayGrp()
                          BuildPostBat()
                          BuildPrice()
                          BuildProcess()
                          BuildProduct()
                          BuildReceipts()
                          BuildTax( )
                          BuildVariety()    // June 2015
                          

                          BuildChqFmt() // Note the Spaces in front of these lines rather than tabs
                          BuildRptCfg( ) // this seems to be the cause of the problems
                          BuildVoid()

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

                            @Bill-Hepler

                            The data in the black code region seems already sorted?

                            What’s the significance of the 3 items below the code box?

                            And I don’t see any leading spaces/tabs anywhere?

                            Matthew EwerM 1 Reply Last reply Reply Quote 1
                            • Matthew EwerM
                              Matthew Ewer @Alan Kilborn
                              last edited by

                              @Alan-Kilborn I suspect what happened there is that the lines DID have tabs and spaces, respectively, when they pasted it into their post, but the tabs caused the black box. The three after used a different whitespace, and so were not included in the black box. (But apparently the whitespace was formatted away?) Note that, if you expect sorting to ignore leading whitespace, the three lines after the box should be interspersed between lines within the box (but are not).

                              Alan KilbornA 1 Reply Last reply Reply Quote 1
                              • Alan KilbornA
                                Alan Kilborn @Matthew Ewer
                                last edited by

                                @Matthew-Ewer

                                That’s a good explanation of what might have happened here.
                                But since the OP never returned to continue the exchange, I suppose the issue is dead.

                                if you expect sorting to ignore leading whitespace

                                Just a note to say that Notepad++'s sorting doesn’t ignore leading whitespace, just in case someone thinks it can from the above.

                                1 Reply Last reply Reply Quote 1
                                • aarocaesA
                                  aarocaes
                                  last edited by

                                  This post is deleted!
                                  1 Reply Last reply Reply Quote 0
                                  • aarocaesA
                                    aarocaes
                                    last edited by

                                    Maybe it could be helpful for anyone else. I had this issue, and the problem was related with the line break codes.

                                    Even if you are seeing different lines, is possible that only one of the line break codes (\n or \r) is being used. If that’s the case, sorting won’t work as it will take all the text as just one single line. You can check this enabling the “Show all characters” option:

                                    2020-10-01 23_00_30-Window.png

                                    LF is the code for Line Feed (\n). But it’s missing the CR (Carriage Return, \r) code. Unlike Unix systems, standard line-termination in Windows and in the Internet is \r\n.

                                    So if you replace these line-termination codes activating the extended search mode (replacing \n with \r\n), it will work.

                                    2020-10-01 22_58_49-Window.png

                                    PeterJonesP 1 Reply Last reply Reply Quote 4
                                    • PeterJonesP
                                      PeterJones @aarocaes
                                      last edited by

                                      @aarocaes ,

                                      Interesting. It sorts correctly for me.
                                      5cdccf20-469c-44e6-a765-074bf01d15ac-image.png

                                      I thought maybe if you have mixed line endings, where some don’t match the current line-endings mode:
                                      94dd079f-50dd-4ff3-ae3a-a124003337e8-image.png => 9cc139ab-cde8-41c8-89d1-10cb24fb14fa-image.png
                                      Yeah, that’s it: correctly\nsorted and these\nlines were treated as single lines.

                                      So, as long as you don’t have mixed line endings, and your line endings match the defined line endings setting shown in the status bar, it will work. But if there’s a mix or discrepancy, it won’t be treated as a line ending.

                                      gitberryG 1 Reply Last reply Reply Quote 4
                                      • gitberryG
                                        gitberry @PeterJones
                                        last edited by

                                        Thank you for these posts - I love everything about NotePad++ EXCEPT line sorting because I’ve never understood why NotePad++ was inconsistent with line sorting until I read this. Now I can use it with more confidence.

                                        On reflection it would seem that this is an unnecessary pain for those who work in all 3 line ending environments and wondering if we couldn’t throw something into settings that could possibly be like this:
                                        [ X ] SORT Line Ending Agnostic (will treat CR, CR-LF and LF equally as line endings when sorting)

                                        Alan KilbornA 2 Replies Last reply Reply Quote 0
                                        • Alan KilbornA
                                          Alan Kilborn @gitberry
                                          last edited by

                                          @gitberry

                                          What is a good example of why someone would need to “mix” line-ending types within one file? I don’t think I’ve ever run across a good reason for this. I welcome being enlightened.

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

                                            @gitberry said in Sort Lines Lexicographically did not work:

                                            Line Ending Agnostic (will treat CR, CR-LF and LF equally as line endings when sorting)

                                            If you read @PeterJones post his last remarks were:
                                            So, as long as you don’t have mixed line endings, and your line endings match the defined line endings setting shown in the status bar, it will work.

                                            So if a file ONLY contains 1 type of line ending and that matches the status bar then sorting will work as expected. This seems to me to be a reasonable assumption by the developers.

                                            Maybe I’m naive when to it comes to the various line endings (Unix, Mac vs Windows) but I don’t see why a file would contain a mixture of the 3 types, unless there had been an error in encoding or reading of the file. So AFAIK a file would ONLY ever contain 1 type of line ending, and that depends on the use/environment the file is being used in.

                                            Notepad++ also has a function which resides under Edit main menu, called EOL Conversion where the file is “totally” converted from one type to another. maybe this should be used before a sort operation if at all unsure of whether there is a mixture of types.

                                            Terry

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