• Login
Community
  • Login

Sorting columns numerically

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 873 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.
  • C
    Cadaver182
    last edited by Dec 17, 2021, 10:31 PM

    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!

    A 1 Reply Last reply Dec 17, 2021, 11:09 PM Reply Quote 0
    • A
      astrosofista @Cadaver182
      last edited by astrosofista Dec 17, 2021, 11:10 PM Dec 17, 2021, 11:09 PM

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

      C 1 Reply Last reply Dec 17, 2021, 11:43 PM Reply Quote 4
      • C
        Cadaver182 @astrosofista
        last edited by Dec 17, 2021, 11:43 PM

        @astrosofista said in Sorting columns numerically:

        Sort Lines as Integers Ascending

        Thanks a lot, works flawlessly!

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