https://github.com/toddself/jortsort
http://jort.technology but in Go
https://github.com/toddself/jortsort
Last synced: 12 months ago
JSON representation
http://jort.technology but in Go
- Host: GitHub
- URL: https://github.com/toddself/jortsort
- Owner: toddself
- Created: 2015-03-03T14:06:52.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-03T15:25:18.000Z (over 11 years ago)
- Last Synced: 2025-07-07T15:13:32.318Z (12 months ago)
- Language: Go
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
[](http://travis-ci.org/toddself/JortSort)
# JortSort
This is an implementation of Jenn Schiffer's famous [JortSort](http://jort.technology) in Go. This will tell you if you need to sort your array or not.
## Installing
`go get github.com/toddself/JortSort`
## Usage
```
import (
"github.com/toddself/JortSort"
"fmt"
)
func Main() {
arr := []string{"a", "b", "c", "d"}
jortArray := jort.Strings2Sortable(arr)
sorted := jort.JortSort(jortArray)
if sorted {
fmt.Println("Your array is sorted")
} else {
fmt.Println("Your array is not sorted")
}
}
```
Since Go is a pain in the ass and "strongly-typed" (whatever that means), I had to implement a generic interface and make that interface sortable. So you need to convert all your arrays into these special sortable types. There are three helper functions for this: `String2Sortable`, `Int2Sortable` and `Float642Sortable`. If you need any other number type, you should re-think your project's data probably.
## Tests
Everything has tests rights?
```
↳ go test -v
=== RUN TestStringSort
--- PASS: TestStringSort (0.00s)
=== RUN TestIntSort
--- PASS: TestIntSort (0.00s)
=== RUN TestStringToSortable
--- PASS: TestStringToSortable (0.00s)
=== RUN TestIntToSortable
--- PASS: TestIntToSortable (0.00s)
=== RUN TestFloat64ToSortable
--- PASS: TestFloat64ToSortable (0.00s)
PASS
ok github.com/toddself/JortSort 0.009s
```
## License
MIT