{"id":22227255,"url":"https://github.com/noir-lang/noir_sort","last_synced_at":"2025-07-27T19:30:57.640Z","repository":{"id":259411596,"uuid":"851443368","full_name":"noir-lang/noir_sort","owner":"noir-lang","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-22T16:20:05.000Z","size":73,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-22T17:39:40.143Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Noir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noir-lang.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-03T05:34:58.000Z","updated_at":"2025-05-22T16:19:54.000Z","dependencies_parsed_at":"2024-10-25T06:43:10.087Z","dependency_job_id":"d9df68ae-4fb2-4fbe-bfa1-504b7cb02151","html_url":"https://github.com/noir-lang/noir_sort","commit_stats":null,"previous_names":["noir-lang/noir_sort"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/noir-lang/noir_sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noir-lang%2Fnoir_sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noir-lang%2Fnoir_sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noir-lang%2Fnoir_sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noir-lang%2Fnoir_sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noir-lang","download_url":"https://codeload.github.com/noir-lang/noir_sort/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noir-lang%2Fnoir_sort/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267413363,"owners_count":24083422,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-12-03T01:01:28.181Z","updated_at":"2025-07-27T19:30:57.633Z","avatar_url":"https://github.com/noir-lang.png","language":"Noir","funding_links":[],"categories":["Libraries"],"sub_categories":["Data Type Manipulation"],"readme":"# noir_sort\n\nEfficiently sorts fixed-sized arrays.\n\n## Noir version compatibility\n\nThis library is tested with all Noir stable releases from v0.36.0.\n\n## Usage\n\n1. Basic usage:\n\n```\nuse dep::sort::sort;\n\nfn foo(a: [u32; 100]) -\u003e [u32; 100] {\n    sort(a) // tadaa\n}\n```\n\n2. Usage with a custom sort function\n\n```\nuse dep::sort::sort_custom;\n\nstruct Entry {\n    key: Field,\n    value: u32\n}\nfn sort_entry(a: Entry, b: Entry) -\u003e bool {\n    a.value \u003c= b.value\n}\n\nfn foo(a: [Entry; 100]) -\u003e [Entry; 100] {\n    sort_custom(a, sort_entry)\n}\n```\n\n3. Usage with an _unconditional_ lte function\n\n```\nfn sort_u16(a: u16, b: u16) -\u003e bool { a \u003c= b }\n\nfn unconditional_lte(a: u16, b: u16) {\n    let diff = (b as Field - a as Field);\n    diff.assert_max_bit_size(16);\n}\n\nfn foo(a: [u16; 100]) -\u003e [u16; 100] {\n    sort_extended(a, sort_u16, unconditional_lte)\n}\n```\n\n## Comments\n\nThe `sort_extended` method is likely to be the most efficient method as asserting that `a \u003c= b` costs fewer constraints than determining whether `a \u003c= b` and assigning a bool to the outcome (e.g. for a `u16`, the `\u003c=` operator needs to constrain the case where `a \u003c= b` and `a \u003e b` and then conditionally assign the return value to the correct case)\n\n## Algorithm Description\n\nThe library executes, in an unconstrained function, a quicksort algorithm to determine the sorted array.\n\nThe library perform two constrained steps:\n\n1. Validates the sorted array contains the same values as the unsorted array (using the `check_shuffle` library)\n2. Validates that, for the sorted array, successive elements are not smaller than previous elements\n\nThe algorithm is highly optimized and the cost is _linear_ in the size of the array.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoir-lang%2Fnoir_sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoir-lang%2Fnoir_sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoir-lang%2Fnoir_sort/lists"}