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

Sort Lines By Selection

by sascha-wolf ST3

A line sort plugin for Sublime Text 3 which enables you to sort lines based on the selected text in the line

Details

Installs

  • Total 4K
  • Win 2K
  • Mac 2K
  • Linux 860
Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21
Windows 0 1 0 2 1 0 1 0 0 1 0 0 0 0 0 3 3 0 0 2 0 2 0 2 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 0
Mac 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
Linux 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0
01234Jul 4Jul 1Jun 28Jun 25Jun 22Jun 19Jun 16Jun 13Jun 10Jun 7Jun 4Jun 1May 29May 26May 23Jul 4 Linux: 0 Mac: 0 Windows: 0Jul 3 Linux: 0 Mac: 0 Windows: 1Jul 2 Linux: 1 Mac: 0 Windows: 0Jul 1 Linux: 0 Mac: 0 Windows: 2Jun 30 Linux: 0 Mac: 0 Windows: 1Jun 29 Linux: 0 Mac: 0 Windows: 0Jun 28 Linux: 0 Mac: 0 Windows: 1Jun 27 Linux: 0 Mac: 0 Windows: 0Jun 26 Linux: 0 Mac: 0 Windows: 0Jun 25 Linux: 0 Mac: 1 Windows: 1Jun 24 Linux: 0 Mac: 1 Windows: 0Jun 23 Linux: 0 Mac: 0 Windows: 0Jun 22 Linux: 1 Mac: 0 Windows: 0Jun 21 Linux: 0 Mac: 0 Windows: 0Jun 20 Linux: 1 Mac: 0 Windows: 0Jun 19 Linux: 0 Mac: 0 Windows: 3Jun 18 Linux: 0 Mac: 0 Windows: 3Jun 17 Linux: 0 Mac: 0 Windows: 0Jun 16 Linux: 0 Mac: 0 Windows: 0Jun 15 Linux: 0 Mac: 0 Windows: 2Jun 14 Linux: 0 Mac: 0 Windows: 0Jun 13 Linux: 0 Mac: 0 Windows: 2Jun 12 Linux: 0 Mac: 0 Windows: 0Jun 11 Linux: 0 Mac: 1 Windows: 2Jun 10 Linux: 0 Mac: 0 Windows: 0Jun 9 Linux: 0 Mac: 1 Windows: 0Jun 8 Linux: 0 Mac: 0 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 0Jun 6 Linux: 0 Mac: 0 Windows: 0Jun 5 Linux: 0 Mac: 0 Windows: 0Jun 4 Linux: 0 Mac: 0 Windows: 0Jun 3 Linux: 0 Mac: 0 Windows: 0Jun 2 Linux: 0 Mac: 0 Windows: 1Jun 1 Linux: 0 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 0 Windows: 0May 30 Linux: 1 Mac: 1 Windows: 0May 29 Linux: 0 Mac: 0 Windows: 1May 28 Linux: 1 Mac: 0 Windows: 1May 27 Linux: 1 Mac: 0 Windows: 0May 26 Linux: 0 Mac: 0 Windows: 0May 25 Linux: 0 Mac: 0 Windows: 0May 24 Linux: 0 Mac: 0 Windows: 0May 23 Linux: 0 Mac: 0 Windows: 0May 22 Linux: 0 Mac: 0 Windows: 1May 21 Linux: 0 Mac: 0 Windows: 0Jul 4 Linux: 0 Mac: 0 Windows: 0Jul 3 Linux: 0 Mac: 0 Windows: 1Jul 2 Linux: 1 Mac: 0 Windows: 0Jul 1 Linux: 0 Mac: 0 Windows: 2Jun 30 Linux: 0 Mac: 0 Windows: 1Jun 29 Linux: 0 Mac: 0 Windows: 0Jun 28 Linux: 0 Mac: 0 Windows: 1Jun 27 Linux: 0 Mac: 0 Windows: 0Jun 26 Linux: 0 Mac: 0 Windows: 0Jun 25 Linux: 0 Mac: 1 Windows: 1Jun 24 Linux: 0 Mac: 1 Windows: 0Jun 23 Linux: 0 Mac: 0 Windows: 0Jun 22 Linux: 1 Mac: 0 Windows: 0Jun 21 Linux: 0 Mac: 0 Windows: 0Jun 20 Linux: 1 Mac: 0 Windows: 0Jun 19 Linux: 0 Mac: 0 Windows: 3Jun 18 Linux: 0 Mac: 0 Windows: 3Jun 17 Linux: 0 Mac: 0 Windows: 0Jun 16 Linux: 0 Mac: 0 Windows: 0Jun 15 Linux: 0 Mac: 0 Windows: 2Jun 14 Linux: 0 Mac: 0 Windows: 0Jun 13 Linux: 0 Mac: 0 Windows: 2Jun 12 Linux: 0 Mac: 0 Windows: 0Jun 11 Linux: 0 Mac: 1 Windows: 2Jun 10 Linux: 0 Mac: 0 Windows: 0Jun 9 Linux: 0 Mac: 1 Windows: 0Jun 8 Linux: 0 Mac: 0 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 0Jun 6 Linux: 0 Mac: 0 Windows: 0Jun 5 Linux: 0 Mac: 0 Windows: 0Jun 4 Linux: 0 Mac: 0 Windows: 0Jun 3 Linux: 0 Mac: 0 Windows: 0Jun 2 Linux: 0 Mac: 0 Windows: 1Jun 1 Linux: 0 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 0 Windows: 0May 30 Linux: 1 Mac: 1 Windows: 0May 29 Linux: 0 Mac: 0 Windows: 1May 28 Linux: 1 Mac: 0 Windows: 1May 27 Linux: 1 Mac: 0 Windows: 0May 26 Linux: 0 Mac: 0 Windows: 0May 25 Linux: 0 Mac: 0 Windows: 0May 24 Linux: 0 Mac: 0 Windows: 0May 23 Linux: 0 Mac: 0 Windows: 0May 22 Linux: 0 Mac: 0 Windows: 1May 21 Linux: 0 Mac: 0 Windows: 0Jul 4 Linux: 0 Mac: 0 Windows: 0Jul 3 Linux: 0 Mac: 0 Windows: 1Jul 2 Linux: 1 Mac: 0 Windows: 0Jul 1 Linux: 0 Mac: 0 Windows: 2Jun 30 Linux: 0 Mac: 0 Windows: 1Jun 29 Linux: 0 Mac: 0 Windows: 0Jun 28 Linux: 0 Mac: 0 Windows: 1Jun 27 Linux: 0 Mac: 0 Windows: 0Jun 26 Linux: 0 Mac: 0 Windows: 0Jun 25 Linux: 0 Mac: 1 Windows: 1Jun 24 Linux: 0 Mac: 1 Windows: 0Jun 23 Linux: 0 Mac: 0 Windows: 0Jun 22 Linux: 1 Mac: 0 Windows: 0Jun 21 Linux: 0 Mac: 0 Windows: 0Jun 20 Linux: 1 Mac: 0 Windows: 0Jun 19 Linux: 0 Mac: 0 Windows: 3Jun 18 Linux: 0 Mac: 0 Windows: 3Jun 17 Linux: 0 Mac: 0 Windows: 0Jun 16 Linux: 0 Mac: 0 Windows: 0Jun 15 Linux: 0 Mac: 0 Windows: 2Jun 14 Linux: 0 Mac: 0 Windows: 0Jun 13 Linux: 0 Mac: 0 Windows: 2Jun 12 Linux: 0 Mac: 0 Windows: 0Jun 11 Linux: 0 Mac: 1 Windows: 2Jun 10 Linux: 0 Mac: 0 Windows: 0Jun 9 Linux: 0 Mac: 1 Windows: 0Jun 8 Linux: 0 Mac: 0 Windows: 0Jun 7 Linux: 0 Mac: 0 Windows: 0Jun 6 Linux: 0 Mac: 0 Windows: 0Jun 5 Linux: 0 Mac: 0 Windows: 0Jun 4 Linux: 0 Mac: 0 Windows: 0Jun 3 Linux: 0 Mac: 0 Windows: 0Jun 2 Linux: 0 Mac: 0 Windows: 1Jun 1 Linux: 0 Mac: 0 Windows: 0May 31 Linux: 0 Mac: 0 Windows: 0May 30 Linux: 1 Mac: 1 Windows: 0May 29 Linux: 0 Mac: 0 Windows: 1May 28 Linux: 1 Mac: 0 Windows: 1May 27 Linux: 1 Mac: 0 Windows: 0May 26 Linux: 0 Mac: 0 Windows: 0May 25 Linux: 0 Mac: 0 Windows: 0May 24 Linux: 0 Mac: 0 Windows: 0May 23 Linux: 0 Mac: 0 Windows: 0May 22 Linux: 0 Mac: 0 Windows: 1May 21 Linux: 0 Mac: 0 Windows: 0

Readme

Source
raw.​githubusercontent.​com

Selection Sorter

Did you ever want to sort some class members via their names, easily, or a number of lines via a string in the middle? Well, now you can.

This plugin enables you to sort lines by the text you have currently selected.

Default Commands

It ships with two commands you can find in the command palette:

  • Sort Lines by Selection
  • Sort Lines by Selection (Case Sensitive)

Customization

The plugin supports custom morphing of the selected strings before sorting, via little python snippets. For example you could reverse the string which is used for sorting, sort via the last character, only via the first etc..

You can make your custom sort available by creating a Default.sublime-commands file in your packages/user folder, or alternatively a keybinding which executes the command.

Example

Here a little example for a custom line sort:

Default.sublime-commands

[
        {
            "caption": "Sort Lines by Selection",
            "command": "sort_lines_by_selection",
            "args": {
                "morph": "s[::-1]" // This will reverse the string
            }
        }
    ]

As you can see I reference a variable s (a string) and reverse it. This would sort the lines by the reversed selection. So a line with a selection of “AZZZZ” would be at the bottom, rather than at the top.

Note however that only a single statement is allowed, otherwise your custom morph will not work.

Technically speaking the morph argument is the “body” of a python lambda, and will be used as the key argument of the built-in sorted function.

Happy sorting!