ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Sort Lines (Numerically)

by alimony ST2/ST3

Sublime Text 2/3 package that adds a command for sorting lines numerically rather than alphabetically.

Details

Installs

  • Total 5K
  • Win 2K
  • OS X 2K
  • Linux 1K
Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28
Windows 1 1 0 1 1 2 0 1 2 0 1 0 1 1 3 0 1 1 2 1 2 1 1 0 0 0 1 0 1 0 0 0 3 3 2 4 3 0 4 1 0 4 1 3 2 0
OS X 1 1 1 0 2 0 4 1 1 1 0 2 2 1 1 2 0 1 2 1 3 1 0 0 1 1 1 3 1 0 0 0 1 1 1 2 0 0 0 1 2 2 0 0 1 1
Linux 0 0 2 0 0 0 0 1 1 0 0 1 2 0 0 1 0 4 2 0 1 2 0 1 1 1 1 0 0 0 0 0 2 1 1 0 3 1 1 0 1 0 0 1 0 0

Readme

Source
raw.​githubusercontent.​com

Sort Lines (Numerically)

Sublime Text 2/3 package that adds a command for sorting lines numerically rather than alphabetically.

Installation

This package is available through Package Control, it’s called “Sort Lines (Numerically)”.

Usage

Just run “Sort Lines (Numerically)” from the Command Palette, or from the Edit menu, which has a keyboard shortcut as well.

Adding a reverse command

This package does not have a reverse option when sorting, since there is already a Reverse command built into Sublime Text. If you want a shortcut for sorting numerically in reverse, you can make one yourself:

In your User package folder, create a file called Sort Lines (Numerically) Reverse.sublime-macro. Edit that file, paste in the following, and save:

[
    {
        "args": null,
        "command": "sort_numerically"
    },
    {
        "args": {
            "operation": "reverse"
        },
        "command": "permute_lines"
    }
]

There will now be a new menu item at Tools > Macros > User > Sort Lines (Numerically) Reverse that when selected will sort numerically and reverse the order. If you want this macro available in the command palette, create a file in your User folder called something like SortLinesNumericallyReverse.sublime-commands containing the following:

[
    {
        "caption": "Sort Lines (Numerically) Reverse",
        "command": "run_macro_file",
        "args": {
            "file": "Packages/User/Sort Lines (Numerically) Reverse.sublime-macro"
        }
    }
]

You will now have a command called Sort Lines (Numerically) Reverse in your command palette. If you want to bind this command to a keyboard shortcut, add something like the following to your default user keymap file (available at Preferences > Key Bindings – User:

{
    "keys": ["ctrl+shift+f5"],
    "command": "run_macro_file",
    "args": {
        "file": "Packages/User/Sort Lines (Numerically) Reverse.sublime-macro"
    }
}

Credits

Thanks to the following contributors: