Indexed by TopGit from live GitHub metadata: Canop/codesort has 103 stars, written primarily in Rust. codesort sorts code
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Your code is full of lists: enum variants, struct fields, match arms, function declarations, etc.
When a list grows, it's sometimes useful to sort it alphabetically, to help you keep track of the parts.
Of course you can't just sort lines: the code wouldn't work anymore; comments and annotations would be lost, spacing would be off, etc.
And sorting code manually is a tedious task.
codesort can do it for you, with a shortcut on the desired part of the code, directly in your IDE.
Here's the before and after of sorting around the cursor's line:
Examples
Sort the variants of a rust enumSort the fields of a rust structSort javascript function assignementsHere, the range to sort has been visually selected.Sort the arms of a huge rust match
Install codesort
Having Rust dev environment installed, run
cargo install codesort
Usage
Sort a range in a file
codesort --range 6:26 src/my/file.rs
Sort around a line
Unless you specifically want to exclude a part of the list from sorting (eg a field you want to keep at the end of a struct), you should prefer to use --around which selects the range for you.
The first example of this readme has been sorted with the following command:
codesort --around 14 src/my/file.rs
Any other line number from 6 to 26 would have been fine, except the deeper lines 21 and 22
(if you sort around line 22, you sort start and end, which is probably not desired).
Sort from stdin, return to stdout
When no path is provided to codesort, specify the language using --lang/-l:
cat some/file.js | codesort -l js
Code Editor Integration
By default, codesort takes the code to sort from stdin and writes the sorted code to stdout.
It can sort either the whole input, a given range (with --range), or select the best range around a given line (using --around).
You can also change the input and output to be files, with --src and --dst.
If necessary, you can provide a filename to codesort for langage detection (the file doesn't have to exist, only the extension of the name will be used, eg .js).
Those options make it easy to integrate codesort in any editor. See below for vim and IntelliJ (contributions welcome for other editors).
Use codesort in vim / neovim
Sort the selection
When you don't want to sort the whole range (for example because there's a specific entry that you want to keep at the beginning), you can specify the range.
Visually select the selection, then type :, then !codesort.
This changes the input to
:'<,'>!codesort
Press the enter key: the selection is sorted with codesort.
Add a binding to sort around the current line
You don't usually have to select the zone to sort.
You can ask codesort to automatically select the zone to sort around your current line.
Define this binding in your vim configuration:
" sort the optimal range around the current line
" See https://github.com/Canop/codesort
nnoremap <Leader>cs ma<ESC>:execute ":%!codesort --around ".line('.')." --detect ".shellescape(expand('%:t'))<CR>`a
Typing the leader key then 'cs' will automatically select the set of blocs around the current line and sort it.
Explanation of the command:
the current position is saved in the a register with ma
the command including the line number is built then executed with :execute
the codesort command takes the current line number through --around
the codesort command takes the filename, for langage detection, through --detect
the previous position is then restored
Use codesort in IntelliJ
sort on a range
Configure the shortcut (File -> Settings -> Tools -> External tools) like this:
No homepage URL was recorded for Canop/codesort in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Does Canop/codesort have any tags?
TopGit's last sync did not record any GitHub topics for Canop/codesort. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on Canop/codesort?
The most recent commit recorded on Canop/codesort was 11 months ago, based on the GitHub push timestamp. The repository has 1 forks — one of the better signals of community interest.
How many stars does Canop/codesort have?
Canop/codesort has 103 GitHub stars — refresh the page for the live number, or check github.com/Canop/codesort. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is Canop/codesort written in?
Canop/codesort is written primarily in Rust. GitHub's language field is based on the largest share of bytes in the default branch.
Where do I read more about Canop/codesort?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/Canop/codesort is the definitive source.
Read full README in the tab above.
Want a second opinion on codesort?
Ask an AI that can read this page — one click and you get its take on codesort.