Sort Lines By Selection
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 846
Apr 2 | Apr 1 | Mar 31 | Mar 30 | Mar 29 | Mar 28 | Mar 27 | Mar 26 | Mar 25 | Mar 24 | Mar 23 | Mar 22 | Mar 21 | Mar 20 | Mar 19 | Mar 18 | Mar 17 | Mar 16 | Mar 15 | Mar 14 | Mar 13 | Mar 12 | Mar 11 | Mar 10 | Mar 9 | Mar 8 | Mar 7 | Mar 6 | Mar 5 | Mar 4 | Mar 3 | Mar 2 | Mar 1 | Feb 28 | Feb 27 | Feb 26 | Feb 25 | Feb 24 | Feb 23 | Feb 22 | Feb 21 | Feb 20 | Feb 19 | Feb 18 | Feb 17 | Feb 16 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 | 0 | 2 | 0 | 0 | 1 | 2 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 3 | 0 | 0 | 1 | 2 | 0 | 1 | 2 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 2 | 0 | 1 | 2 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 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!