https://github.com/gregoryv/order
Package order provides custom sorting of lines
https://github.com/gregoryv/order
Last synced: 8 months ago
JSON representation
Package order provides custom sorting of lines
- Host: GitHub
- URL: https://github.com/gregoryv/order
- Owner: gregoryv
- License: mit
- Created: 2021-05-02T06:31:00.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-04-08T06:51:22.000Z (about 3 years ago)
- Last Synced: 2025-03-30T05:13:17.554Z (about 1 year ago)
- Language: Go
- Size: 158 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
Package [order](https://pkg.go.dev/github.com/gregoryv/order) provides custom sorting of lines.
Initial purpose is to sort project directories and its
files in a more logic manner. Ie. a directory structure is
basically a tree but when designing a project we look at it in
terms of layers and concepts.
## Quick start
$ go install github.com/gregoryv/order/cmd/order@latest
$ order --help

## Example
lines := []string{
"bypattern.go",
"bypattern_test.go",
"changelog.md",
"cmd",
"go.mod",
"go.sum",
"LICENSE",
"README.md",
}
patterns := []string{
"README",
"LICENSE",
`\.md`,
`go\.[mod|sum]`,
"cmd",
}
sort.Sort(order.LinesByPattern(lines, patterns))
for _, line := range lines {
fmt.Println(line)
}
// output:
// README.md
// LICENSE
// changelog.md
// go.mod
// go.sum
// cmd
// bypattern.go
// bypattern_test.go