• Login
Community
  • Login

Long line, into multiple in numerical order

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 315 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.
  • L
    Luis Lucena
    last edited by Luis Lucena Feb 18, 2023, 3:34 PM Feb 18, 2023, 3:33 PM

    Hello, I am trying to sort a long line containing numbers and text into lines by numerical order contained in that same line.

    Here is what I am starting with:

    Line 1 0 “Alex” 1 “Steve” 2 “Kevin” 3 “Peter”

    Here is how I will line to be sorted:

    Line 1: 0 “Alex”
    Line 2: 1 “Steve”
    Line 3: 2 “Kevin”
    Line 4: 3 “Peter”

    D 1 Reply Last reply Feb 18, 2023, 5:33 PM Reply Quote 0
    • D
      David Brigden52 @Luis Lucena
      last edited by Feb 18, 2023, 5:33 PM

      @Luis-Lucena you can do this in your example using the replace dialog (extended replace).

      Finddouble quote and space. Replace All with double quote and \r\n.

      I suspect you need something more complicated.

      What if the original line is not sorted?
      Is your text always enclosed in quotes?
      Does your text ever have leading spaces?

      Give us an example that is ugly, something closer to a worst case.

      L 1 Reply Last reply Feb 18, 2023, 7:18 PM Reply Quote 0
      • L
        Luis Lucena @David Brigden52
        last edited by Feb 18, 2023, 7:18 PM

        @David-Brigden52 I have tried replace dialog.

        For find what I entered a “space”
        For replace with I entered “\r\n”

        However this gets me the following

        Line 1: 0
        Line 2: “Alex”
        Line 3: 1
        Line 4: “Steve”
        Line 5: 2
        Line 6: “Kevin”
        Line 7: 3
        Line 8: “Peter”

        I am looking to keep the number along with with value.

        Line 1: 0 “Alex”
        Line 2: 1 “Steve”
        Line 3: 2 “Kevin”
        Line 4: 3 “Peter”

        A 1 Reply Last reply Feb 18, 2023, 7:26 PM Reply Quote 0
        • A
          Alan Kilborn @Luis Lucena
          last edited by Feb 18, 2023, 7:26 PM

          @Luis-Lucena said in Long line, into multiple in numerical order:

          For find what I entered a “space”

          Really? That’s what you tried? Did you think about what that might do before you did it? If you were attempting to follow the suggestion of @David-Brigden52 , I think you fell short; way short…

          L 1 Reply Last reply Feb 18, 2023, 7:35 PM Reply Quote 0
          • L
            Luis Lucena @Alan Kilborn
            last edited by Feb 18, 2023, 7:35 PM

            @Alan-Kilborn @David-Brigden52

            I got it. thanks for the help.

            I am new at this and learning.

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