https://github.com/tomnomnom/blocksort
A tool for sorting blocks of lines
https://github.com/tomnomnom/blocksort
Last synced: about 2 months ago
JSON representation
A tool for sorting blocks of lines
- Host: GitHub
- URL: https://github.com/tomnomnom/blocksort
- Owner: tomnomnom
- Created: 2022-10-04T20:54:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-04T20:59:16.000Z (over 2 years ago)
- Last Synced: 2025-03-01T12:43:56.661Z (2 months ago)
- Language: Go
- Size: 1.95 KB
- Stars: 39
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# blocksort
A tool for sorting blocks of lines.
## Install
```
go install github.com/tomnomnom/blocksort@latest
```## Usage
Given some blocks of lines on `stdin`:
```
▶ cat blocks.txt
Block C
Item 2
Item 1
Block A
Item 3
Item 2
Block B
Item 5
Item 3
```They can be sorted by a specific line (defaulting to the first line):
```
▶ cat blocks.txt | blocksort -n3
Block A
Item 3
Item 2
Block B
Item 5
Item 3
Block C
Item 2
Item 1
```The `-n`/`--number` flag sets how many lines are in each block.
The `-i`/`--index` flag sets which line in the block to use when sorting.Get help with `-h`:
```
▶ blocksort -h
Usage of blocksort:
-i, --index int Which line to sort by (0-indexed)
-n, --number int Number of lines per block (default 3)
-r, --reverse Reverse sort order
pflag: help requested
```## Credit
Built for [@digininja](https://github.com/digininja) as a result of
[this Twitter thread](https://twitter.com/digininja/status/1577331330567766016).