{"id":13786660,"url":"https://github.com/jfcg/sorty","last_synced_at":"2025-05-11T22:32:00.545Z","repository":{"id":57493041,"uuid":"171356050","full_name":"jfcg/sorty","owner":"jfcg","description":":zap: Fast Concurrent / Parallel Sorting in Go","archived":false,"fork":false,"pushed_at":"2024-05-11T07:11:10.000Z","size":357,"stargazers_count":133,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-17T22:36:26.974Z","etag":null,"topics":["concurrency","golang","parallelism","parameter-tuning","sorting"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jfcg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-18T21:05:45.000Z","updated_at":"2024-11-09T09:39:07.000Z","dependencies_parsed_at":"2024-06-18T18:17:00.514Z","dependency_job_id":"7429d21f-b7b1-44ba-8c1c-79cb397483b1","html_url":"https://github.com/jfcg/sorty","commit_stats":null,"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fsorty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fsorty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fsorty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfcg%2Fsorty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfcg","download_url":"https://codeload.github.com/jfcg/sorty/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253645314,"owners_count":21941314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","golang","parallelism","parameter-tuning","sorting"],"created_at":"2024-08-03T19:01:27.387Z","updated_at":"2025-05-11T22:31:55.528Z","avatar_url":"https://github.com/jfcg.png","language":"Go","readme":"## sorty [![go.dev ref](https://pkg.go.dev/static/frontend/badge/badge.svg)](https://pkg.go.dev/github.com/jfcg/sorty/v2#pkg-overview) [![report card](https://goreportcard.com/badge/github.com/jfcg/sorty/v2)](https://goreportcard.com/report/github.com/jfcg/sorty/v2) [![coverage](./.github/cover.svg)](https://github.com/jfcg/sorty/actions/workflows/QA.yml)\n\nsorty is a type-specific, fast, efficient, concurrent / parallel sorting\nlibrary. It is an innovative [QuickSort](https://en.wikipedia.org/wiki/Quicksort)\nimplementation, hence in-place and does not require extra memory. You can call:\n```go\nimport \"github.com/jfcg/sorty/v2\"\n\nsorty.SortSlice(native_slice) // []int, []float64, []string etc. in ascending order\nsorty.SortLen(len_slice)      // []string or [][]T 'by length' in ascending order\nsorty.Sort(n, lesswap)        // lesswap() based\n```\nIf you have a pair of `Less()` and `Swap()`, then you can trivially write your\n[`lesswap()`](https://pkg.go.dev/github.com/jfcg/sorty/v2#Sort) and sort your generic\ncollections using multiple CPU cores quickly.\n\nsorty natively [sorts](https://pkg.go.dev/github.com/jfcg/sorty/v2#SortSlice) any type equivalent to\n```go\n[]int, []int32, []int64, []uint, []uint32, []uint64,\n[]uintptr, []float32, []float64, []string, [][]byte,\n[]unsafe.Pointer, []*T // for any type T\n```\nsorty also natively sorts any type equivalent to `[]string` or `[][]T` (for any type `T`)\n[by length](https://pkg.go.dev/github.com/jfcg/sorty/v2#SortLen).\n\nsorty is stable (as in version), well-tested and pretty careful with resources \u0026 performance:\n- `lesswap()` operates [**faster**](https://github.com/lynxkite/lynxkite/pull/141#issuecomment-779673635)\nthan [`sort.Interface`](https://pkg.go.dev/sort#Interface) on generic collections.\n- For each `Sort*()` call, sorty uses up to [`MaxGor`](https://pkg.go.dev/github.com/jfcg/sorty/v2#pkg-variables)\nconcurrent goroutines (3 by default including caller) and up to one channel.\n- Goroutines and channel are created/used **only when necessary**.\n- `MaxGor ≤ 1` (or a short input) yields single-goroutine sorting: no goroutines or channel will be created.\n- `MaxGor` can be changed live, even during ongoing `Sort*()` calls.\n- [`MaxLen*`](https://pkg.go.dev/github.com/jfcg/sorty/v2#pkg-constants) parameters are\ntuned to get the best performance, see below.\n- sorty can handle [NaNs](https://en.wikipedia.org/wiki/NaN) with [`NaNoption`](https://pkg.go.dev/github.com/jfcg/sorty/v2#pkg-variables).\n- sorty API adheres to [semantic](https://semver.org) versioning.\n\nsorty does not yet recognize partially sorted (sub-)slices to sort them faster (like pdqsort).\n\n### Benchmarks\nSee `Green tick \u003e QA / Tests \u003e Details`. Testing and benchmarks are done with random inputs\nvia [jfcg/rng](https://github.com/jfcg/rng) library.\n\n### Testing \u0026 Parameter Tuning\nRun tests with:\n```\ngo test -timeout 1h -v\n```\nYou can tune `MaxLen*` for your platform/CPU with:\n```\ngo test -timeout 3h -tags tuneparam\n```\nNow you can update `MaxLen*` in `maxc.go` and run tests again to see the improvements.\nThe parameters are already set to give good performance over different CPUs.\nAlso see `Green tick \u003e QA / Tuning \u003e Details`.\n\n### Support\nSee [Contributing](./.github/CONTRIBUTING.md), [Security](./.github/SECURITY.md) and [Support](./.github/SUPPORT.md) guides. Also if you use sorty and like it, please support via [Github Sponsors](https://github.com/sponsors/jfcg) or:\n- BTC:`bc1qr8m7n0w3xes6ckmau02s47a23e84umujej822e`\n- ETH:`0x3a844321042D8f7c5BB2f7AB17e20273CA6277f6`\n","funding_links":["https://github.com/sponsors/jfcg"],"categories":["工具库","Utilities","公用事业公司","工具库`可以提升效率的通用代码库和工具`","Utility"],"sub_categories":["查询语","Utility/Miscellaneous","实用程序/Miscellaneous","HTTP Clients","Fail injection"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfcg%2Fsorty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfcg%2Fsorty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfcg%2Fsorty/lists"}