Sorts
Parallel and radix sorting in Go
Install / Use
/learn @twotwotwo/SortsREADME
sorts
sorts provides parallel radix sorting by a string, []byte, or (u)int64 key, and a parallel Quicksort(data). sorts/sortutil sorts common slice types and adds functions to help sort floats.
Usually, stick to stdlib sort: that's fast, standard, and simpler. But this package may help if sorting huge datasets is a bottleneck for you. To get a sense of the potential gains, some timings are available.
To radix sort, implement sort.Interface plus one more method, Key(i int), returning the key for an item as string/[]byte/(u)int64, and call sorts.ByString, ByBytes, ByUint64, or ByInt64. See the godoc for details and examples: http://godoc.org/github.com/twotwotwo/sorts
There's no Reverse(), but sorts.Flip(data) will flip ascending-sorted data to descending. There's no stable sort. The string sorts just compare byte values; é won't sort next to e. Set sorts.MaxProcs if you want to limit concurrency. The package checks that data is sorted after every run and panics(!) if not.
Credit (but no blame, or claim of endorsement) to the authors of stdlib sort; this uses its qSort, tests, and interface, and the clarity of its code helped make this possible.
I'd love to hear if you're using this. E-mail me at my github username at GMail, or say hey on Twitter (@rf).
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
