Community
    • Login

    Lexicographically ascending with index

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 4 Posters 476 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.
    • Amazon BooksA
      Amazon Books
      last edited by

      Hello, how can we retrieve the index values of the ascending sort data while performing a lexicographical ascend?
      For example:

      cat
      ant
      bat
      elephant
      dog
      

      will get sorted as

      ant
      bat
      cat
      dog
      elephant
      

      but how to get the index values of this sort, i.e.

      2
      3
      1
      5
      4
      

      Thanks.

      Lycan ThropeL Neil SchipperN 2 Replies Last reply Reply Quote 0
      • Lycan ThropeL
        Lycan Thrope @Amazon Books
        last edited by

        @amazon-books
        The same way you’s sort the word list. Using your list of numbers, I just sorted it Lexicographically Ascending as the screenshots show.
        LexNumbers1.PNG

        Using the Edit Menu:
        LexNumbers2.PNG

        And Viola:
        LexNumbers3.PNG

        Lee

        1 Reply Last reply Reply Quote 1
        • Amazon BooksA
          Amazon Books
          last edited by

          No, not like this.
          The list is linguistic-only, made of words, not numbers.
          ‘Ant’ is at line#2, hence when the list of animals is sorted alphabetically, it rises to the top and occupies position#1. However, in the original list, its index-value was 2. How to recover this index value?
          Similarly, the word ‘Dog’ was at line#5 before sorting. After sort, its position is at line#4. How to get the information that its original index-value was 5?
          Here is the table of new versus old index-values of the given animal list:

          new   old
          1      2
          2      3
          3      1
          4      5
          5      4
          

          How can we get this table? The list to be sorted is non-numerical, containing only words.

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Neil SchipperN
            Neil Schipper @Amazon Books
            last edited by

            @amazon-books You can insert a column of ascending numbers to the right of your text. See Edit|Column Editor.

            After sorting, you can use column select (Alt-mouse, or Alt-Shift-arrows) and cut, and perhaps Edit|Blank Operations|Trim Trailing to clean up.

            What you’re trying to do is done much more naturally in a spreadsheet.

            Amazon BooksA 1 Reply Last reply Reply Quote 3
            • Alan KilbornA
              Alan Kilborn @Amazon Books
              last edited by

              @amazon-books

              Elaborating on Neil’s reply:

              Hold Alt while left-clicking on the first line, in the whitespace out to the far right (in a column number greater than the length of the longest line you are going to sort), and then drag down in the same column, to get a “selection” that looks like this:

              652a3399-39d8-4898-8214-b77786a0132a-image.png

              Press Alt+c and set up the box that appears like this:

              b6437006-8c5f-405c-893c-8849c89a4c6d-image.png

              Press OK and your data will be transformed like this:

              fa01a760-ddae-4603-95a7-61e96c0be22a-image.png

              Do your sort to obtain:

              5b41c902-ad98-44a3-957b-2b4e1f8b7ac2-image.png

              Amazon BooksA 1 Reply Last reply Reply Quote 3
              • Amazon BooksA
                Amazon Books @Alan Kilborn
                last edited by

                @alan-kilborn Many thanks.

                1 Reply Last reply Reply Quote 0
                • Amazon BooksA
                  Amazon Books @Neil Schipper
                  last edited by

                  @neil-schipper Thanks.

                  1 Reply Last reply Reply Quote 0
                  • Neil SchipperN Neil Schipper referenced this topic on
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors