- Sort
- Sort lines by content or length in the editor.
- 2435 Installs
Readme
Sort
Extension for nova.app that allows you to perform simple sorting on selections.
Usage
Currently you can sort in 6 different ways:
- Sort inline
- Sort inline (case sensitive)
- Sort lines alphanumerically
- Sort lines alphanumerically (case sensitive)
- Sort lines based on length
- Sort lines based on length (reversed)
Examples
// 1. Sort inline
cba120 --> 012abc
// if case sensitive
cba120CBA --> 012aAbBcC
// 2. Sort inline (multiline)
cba
210
// Becomes
abc
012
// 3. Sort lines (case sensitive)
ABC
abc
123
// Becomes
123
abc
ABC
// and
ABC1
abc2
// Becomes
ABC1
abc2 // the numbers matter more than the case.
// It is worth mentioning that because the use case for the sorting is programming
// we do not take into account numbers currently. Meaning that:
1
2
10
// Becomes
1
10
2
// 4. Sort lines (case insensitive)
ABC
abc
123
// Becomes
123
ABC
abc
// 5. Sort lines based on length
aaa
aa
a
// Becomes
a
aa
aaa
// 6. Sort lines (length reversed)
b
bbb
bb
bbbb
// Becomes
bbbb
bbb
bb
b
Sorting
Behind the scenes we are using the Intl.Collator for the sorting. Since we are not hardcoding the locale I suspect the sorting will actually be slightly different depending on your locale and the language you are sorting, but I am not sure. If this is the case that's fantastic!. If you can confirm or deny this please open an issue with some examples.
Changelog
Version 2.2.0 (2023-04-16)
Spring cleaning.
- [MAINTENANCE] Node 18, Add @chrisdl as codeowner, update npm packages, update github actions versions. #17
- [MAINTENANCE] Fix variable name readability issue deepsource was complaining about. #16
Version 2.1.0 (2022-04-27)
Attempt to detect numeric (currently very basic, works only if you are sorting numbers, not strings of numbers for example) values in what is being sorted and add the numeric: true
configuration to the Intl.Collator sorter to make it sort the numbers properly.
- [FEATURE] Add numeric detection #14
Version 2.0.0 (2022-01-24)
This version changes how the sorting works. We used to use the built in javascript .sort()
but it behaved in a way that users did not find intuitive (especially regarding uppercase vs lowercase). This version uses a new sorting algorithm (which you can see in utils.js
) that uses the Intl.Collator for better sorting. It also adds a case-insensitive mode.
- [FEATURE] Updating the sorting algorithm to use Intl.Collator #12
- [FEATURE] Adds case insensitive sorting. #12
- [DOCS] Update docs to be very specific about what sorting behavior users can expect #12
Version 1.3.7 (2021-01-21)
- [FEATURE] New Logo Yay! #9
- [DOCS] Adding gif to readme to show usage. #10
- [DOCS] Adding some examples to the readme. #11
Version 1.3.3 (2020-11-20)
- [FEATURE] remove the stupid
-->
arrows from the command names. #3 - [DEV] adding eslint and standardjs. #2
- Switching to semver.
- [FEATURE] Support for sorting across multiple ranges. #1
Version 1.2 (2020-10-27)
Added a picture to readme to make it more obvious what the extension does.
Version 1.1 (2020-10-17)
Readme updates.
Version 1.0 (2020-10-17)
Initial release.