| 1 | # [sorts](http://godoc.org/github.com/twotwotwo/sorts) |
| 2 | |
| 3 | [sorts](http://godoc.org/github.com/twotwotwo/sorts) provides |
| 4 | parallel radix sorting by a string, []byte, or (u)int64 key, and a parallel |
| 5 | Quicksort(data). |
| 6 | [sorts/sortutil](http://godoc.org/github.com/twotwotwo/sorts/sortutil) |
| 7 | sorts common slice types and adds functions to help sort floats. |
| 8 | |
| 9 | Usually, stick to stdlib sort: that's fast, standard, and simpler. But this |
| 10 | package may help if sorting huge datasets is a bottleneck for you. To get a |
| 11 | sense of the potential gains, [some timings are available](https://docs.google.com/spreadsheets/d/1GkXMLXQ7oW5Bp0qwyYw0IiQElIq8B-IvNEYE_RPCTvA/edit#gid=0). |
| 12 | |
| 13 | To radix sort, |
| 14 | [implement sort.Interface](http://golang.org/pkg/sort/#Interface) |
| 15 | plus one more method, Key(i int), returning the key for an item as |
| 16 | string/[]byte/(u)int64, and call sorts.ByString, ByBytes, ByUint64, or |
| 17 | ByInt64. See the godoc for details and examples: |
| 18 | http://godoc.org/github.com/twotwotwo/sorts |
| 19 | |
| 20 | There's no Reverse(), but sorts.Flip(data) will flip ascending-sorted |
| 21 | data to descending. There's no stable sort. The string sorts just compare |
| 22 | byte values; é won't sort next to e. Set sorts.MaxProcs if you want to |
| 23 | limit concurrency. The package checks that data is sorted after every run |
| 24 | and panics(!) if not. |
| 25 | |
| 26 | Credit (but no blame, or claim of endorsement) to the authors of stdlib sort; |
| 27 | this uses its qSort, tests, and interface, and the clarity of its code |
| 28 | helped make this possible. |
| 29 | |
| 30 | I'd love to hear if you're using this. E-mail me at my github username at |
| 31 | GMail, or say hey on Twitter ([@rf](http://twitter.com/rf/)). |