Community
    • Login

    Sorting columns numerically

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.1k Views 1 Watching
    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.
    • Cadaver182C Offline
      Cadaver182
      last edited by

      Hi, I need help, I want to sort a list, but the numbers that I want to sort are in a different column, how I can achieve the sorting?, here is the text that I’m refering:

      Blazing Nova [NEW!] Total= 058
      AutoMag .44 Total= 046
      KelTec KSG-12 Total= 116
      FAMAS G2 Platinum Total= 097
      Transcendent Magnum Drill GoldTotal= 038
      Barrett M107 Platinum Total= 031
      SG-552 Cerberus [NEW!] Total= 069
      AK-47 Paladin Chimera Total= 035
      AA-12 Gold Total= 013
      M4A1 Dark Knight Chimera Total= 035
      Mk. 14 EBR Gold Total= 029
      Barrett M95 White Tiger Total= 183
      M249 Phoenix Total= 040
      AWP Elven Ranger Total= 151
      AUG Guardian Total= 063
      SCAR OZ-D Total= 101
      SG-552 Lycanthrope Total= 092
      Barrett M95 Ghost Knight Total= 139
      Desert Eagle Crimson Hunter Chimera Total= 087
      M4A1 Dark Knight Total= 092
      AK-47 Paladin Total= 126
      Tempest Total= 401
      XM556 Microgun Total= 043
      [Half-Life 2] Combine Emplacement Gun Total= 044
      [Half-Life 2] MP7 Total= 730
      [Insurgency] L85A2-L123A2 Total= 050
      [Insurgency] M79 Total= 133
      Pacman-Launcher Total= 104
      Jetpack Total= 012
      [Counter-Strike 1.6] Knife Total= 131
      [Counter-Strike 1.6] C4 Total= 011
      [Counter-Strike 1.6] AK-47 Total= 216
      [Counter-Strike 1.6] M4A1 Total= 253
      [Counter-Strike 1.6] P90 Total= 024

      I want them to sort like:
      xxxxxx Total= 010
      xxxxxx Total= 015
      xxxxxx Total= 037

      Thanks!

      astrosofistaA 1 Reply Last reply Reply Quote 0
      • astrosofistaA Offline
        astrosofista @Cadaver182
        last edited by astrosofista

        @cadaver182

        It’s doable with RegEx, but not in one step, as follows:

        a) Open the Replace dialog (Ctrl + H) and type:

        Search: (?-s).* (\d+)$
        Replace: $1 $0
        

        Put the caret at the very beginning of the document, select the Regular Expression mode and click on Replace All. You will get a new list like

        058 Blazing Nova [NEW!] Total= 058
        046 AutoMag .44 Total= 046
        116 KelTec KSG-12 Total= 116
        097 FAMAS G2 Platinum Total= 097
        038 Transcendent Magnum Drill GoldTotal= 038
        ...
        

        b) Choose Edit > Sort Lines as Integers Ascending, to get

        011 [Counter-Strike 1.6] C4 Total= 011
        012 Jetpack Total= 012
        013 AA-12 Gold Total= 013
        024 [Counter-Strike 1.6] P90 Total= 024
        029 Mk. 14 EBR Gold Total= 029
        

        c) Lastly, remove the auxiliary integers with this other RegEx —same instructions as above—:

        Search: (?-s)^(\d+)\x20
        Replace: [leave empty]
        

        That’s all.

        Cadaver182C 1 Reply Last reply Reply Quote 4
        • Cadaver182C Offline
          Cadaver182 @astrosofista
          last edited by

          @astrosofista said in Sorting columns numerically:

          Sort Lines as Integers Ascending

          Thanks a lot, works flawlessly!

          1 Reply Last reply Reply Quote 2

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors