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

Sort​By

by Doi9t ALL

A Sublime Text plugin that allows you to sort lines with methods that are not present by default.

Labels sort, sorting

Details

  • 2.1.0
    1.2.0
  • github.​com
  • github.​com
  • 2 years ago
  • 2 hours ago
  • 11 years ago

Installs

  • Total 17K
  • Win 8K
  • Mac 6K
  • Linux 3K
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 29 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 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9 Feb 8 Feb 7 Feb 6 Feb 5 Feb 4 Feb 3
Windows 0 1 1 2 0 4 1 2 1 4 1 3 3 2 2 3 1 0 1 2 0 2 1 2 2 3 0 5 0 1 2 0 1 0 2 1 1 2 3 1 1 1 1 3 1 1
Mac 1 1 1 0 2 2 1 3 2 0 0 1 0 3 1 2 2 0 0 3 1 5 1 0 0 1 0 3 0 3 0 2 1 0 2 1 1 0 1 0 2 1 3 0 1 0
Linux 0 1 0 1 0 1 0 5 1 1 1 0 0 0 1 1 0 1 2 2 0 1 0 0 0 1 2 1 1 2 0 0 1 0 0 1 1 0 1 0 2 0 1 1 1 0

Readme

Source
raw.​githubusercontent.​com

SortBy

A Sublime Text plugin that allows you to sort lines with methods that are not present by default.


Feature matrix

Features ST2 ST3 ST4 Description
Natural order x x x Sort the lines using the natural order, you can read more in an excellent article by Jeff Atwood.
Sort by the length of lines x x x
Sort lines of text alphabetically x x x
Sort numbers numerically x x x
Semantic Versioning x x Sort Semantic Versions, not supporting pre-releases / build metadata at the moment.
Regular expression x x Sort the lines using a regex, to find the component and choose a subsort for the line.

You can check the backward-incompatible-changes file to see if you need to do something to keep your current settings / workflow.

  1. Able to sort the entire file (when there is no selection)
  2. Case sensitivity option for the alphabetically sort method (Editable in SortBy.sublime-settings)

Installation

With Package Control

CTRL + SHIFT + P on Windows/Linux. COMMAND + SHIFT + P on OS X. and type SortBy in the box.

Manual installation

  1. Find your local Sublime Text Packages directory.
  2. Copy the SortBy directory inside the Packages directory.
  3. Restart Sublime Text and enjoy !

How to use

  1. Select the text you want to sort.
  2. Go in the menu Tools, Packages then you should see SortBy.
  3. Choose your option. (Either Reverse or normal).

Settings

Sorts

handle_selected_part_of_line_as_full_selected_line

Enable this (true) to ignore the start & end of the selection; any line that is touching the selection, will be sorted.

alphabetically_case_sensitive

Enable this (true) to sort with the case sensitivity (the lower and the upper cases will be sorted in two different groups).

Subsorts

Length of lines

This Subsort is disabled by default.

You can sort the line of the same length alphabetically. To enable this subsort, add the subsort_length_of_line property with the value ALPHABETICALLY OR ALPHABETICALLY_DESCENDING in the plugin settings.

Key Bindings

Create the file

  1. In the Preferences menu
  2. Go to Package settings
  3. Go to SortBy
  4. Click on Key Bindings - User

This will open / create a key bind file for the entire application.

Change the key binding

When the file is created or opened, you need to override the key binding that you want.

  1. Copy the key binding from Default.sublime-keymap that you want to override (copy the entire JSON object). Example
{
    "caption": "SortBy: Natural order",
    "keys": [
      "ctrl+shift+alt+q"
    ],
    "command": "srtbyli",
    "args": {
      "sort": "natural_order",
      "reversed": false
    }
  }

In this example, the key bind is ctrl+shift+alt+q

  1. With the JSON object in your clipboard, add it to the created file, by making sure to wrap it in a JSON array ([...]). Example
[  
  {
    "caption": "SortBy: Natural order",
    "keys": [
      "ctrl+shift+alt+q"
    ],
    "command": "srtbyli",
    "args": {
      "sort": "natural_order",
      "reversed": false
    }
  }
]
  1. Change the keys to the key binding that you want.

Disable the old key binding

If the old key binding is causing issues, you can disable it with the following JSON objet; just add it to the created file.

{
    "keys": [
      "ctrl+shift+alt+u"
    ],
    "command": "noop"
  }