{"id":50398519,"url":"https://github.com/programmersd21/ordr","last_synced_at":"2026-06-05T03:00:58.885Z","repository":{"id":361189362,"uuid":"1253465947","full_name":"programmersd21/ordr","owner":"programmersd21","description":"⚡ High-performance sorting library for Python, powered by Rust 🦀 - featuring parallel, adaptive, and radix-sort backends for blazing-fast performance.","archived":false,"fork":false,"pushed_at":"2026-05-29T15:10:17.000Z","size":751,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-02T00:24:46.036Z","etag":null,"topics":["benchmark","data-structures","fast","high-performance","introsort","numpy","parallel-sorting","pdqsort","performance","pyo3","python","python-sorting","quicksort","radix-sort","rust","rust-python","sorting","sorting-algorithms","timsort"],"latest_commit_sha":null,"homepage":"https://programmersd21.github.io/ordr/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/programmersd21.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-29T13:45:02.000Z","updated_at":"2026-05-29T15:10:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/programmersd21/ordr","commit_stats":null,"previous_names":["programmersd21/ordr"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/programmersd21/ordr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmersd21%2Fordr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmersd21%2Fordr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmersd21%2Fordr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmersd21%2Fordr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/programmersd21","download_url":"https://codeload.github.com/programmersd21/ordr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmersd21%2Fordr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33843611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"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":["benchmark","data-structures","fast","high-performance","introsort","numpy","parallel-sorting","pdqsort","performance","pyo3","python","python-sorting","quicksort","radix-sort","rust","rust-python","sorting","sorting-algorithms","timsort"],"created_at":"2026-05-30T22:01:30.588Z","updated_at":"2026-06-03T01:00:48.974Z","avatar_url":"https://github.com/programmersd21.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ordr\n\n[![CI](https://img.shields.io/github/actions/workflow/status/programmersd21/ordr/ci.yml?style=for-the-badge\u0026logo=github\u0026label=CI)](https://github.com/programmersd21/ordr/actions/workflows/ci.yml)\n[![Python](https://img.shields.io/badge/python-3.10%2B-blue?style=for-the-badge\u0026logo=python\u0026logoColor=white)](https://www.python.org/)\n[![Rust](https://img.shields.io/badge/rust-1.70%2B-orange?style=for-the-badge\u0026logo=rust\u0026logoColor=white)](https://www.rust-lang.org/)\n[![License](https://img.shields.io/badge/license-MIT-green?style=for-the-badge)](https://opensource.org/licenses/MIT)\n\n\u003e **High-performance adaptive sorting for Python, powered by Rust.**\n\n`ordr` is a professional sorting library that bridges the gap between Python's ergonomics and Rust's raw performance. It features a suite of optimized sorting algorithms and an intelligent adaptive dispatch engine that selects the best strategy for your data.\n\n## Key Features\n\n- **Adaptive Dispatch (`ordr.smart`)**: Automatically chooses the best algorithm by inspecting data characteristics (size, presortedness, duplicate ratio, value range).\n- **High Performance**: Core algorithms implemented in Rust with heavy optimizations (branchless partition, prefetching, LTO).\n- **Parallel Sorting**: Leverages Rayon for multi-threaded sorting of massive datasets.\n- **NumPy Integration**: Accepts numpy arrays directly with zero-copy in-place sorting.\n- **Modern Algorithms**: Includes PDQSort (Pattern-Defeating Quicksort), TimSort, IntroSort, Radix Sort, and sorting networks for small arrays.\n- **Developer Tools**: Built-in benchmarking suite, terminal-based sorting visualizer, and hyperfine benchmarking scripts.\n\n## Installation\n\n```bash\npip install ordr-python\n```\n\n*(Note: Requires a Rust compiler for source builds. Pre-built wheels are available from PyPI.)*\n\n## Usage\n\n### Basic Sorting\n\n```python\nimport ordr\nimport random\n\ndata = [random.randint(0, 1000) for _ in range(10000)]\n\n# Use the adaptive smart sort (recommended)\nsorted_data = ordr.smart(data)\n\n# Or choose a specific algorithm\nsorted_data = ordr.pdq(data)             # Pattern-Defeating Quicksort\nsorted_data = ordr.tim(data)             # TimSort (stable)\nsorted_data = ordr.par_sort(data)        # Parallel stable sort\nsorted_data = ordr.par_sort_unstable(data) # Parallel unstable sort\nsorted_data = ordr.radix(data)           # Radix sort for integers\n```\n\n### NumPy Support\n\n```python\nimport numpy as np\nimport ordr\n\narr = np.array([3, 1, 4, 1, 5], dtype=np.int64)\nordr.smart(arr)  # Sorts in-place, zero-copy\nprint(arr)       # [1, 1, 3, 4, 5]\n```\n\n### Development Scripts\n\nThe repository includes several utility scripts for common development tasks:\n\n- **Build**: `python build_lib.py` builds the Rust extension and creates wheels in the `build/` directory.\n- **Lint**: `python lint.py` runs Ruff (formatting and linting), Mypy, cargo fmt, cargo clippy, and pytest.\n- **Benchmarks**: `make bench algo=\u003calgo\u003e size=\u003cN\u003e pattern=\u003cpattern\u003e` runs hyperfine for a single algorithm. Low-level: `python bench_hyperfine.py generate \u003csize\u003e \u003cpattern\u003e \u003coutfile\u003e` to prepare data, then `python bench_hyperfine.py run \u003calgo\u003e \u003cdatafile\u003e` to time.\n- **Examples**: `python run_examples.py` runs all scripts in the `examples/` directory.\n\n### Benchmarking\n\n`ordr` comes with a first-class benchmarking suite to compare performance against Python's built-in `sorted()`.\n\n```python\nfrom ordr.benchmark import compare, display_comparison\n\n# Compare ordr.smart against Python's sorted()\nresults = compare(size=10000, pattern=\"random\")\ndisplay_comparison(results)\n```\n\nRun `make bench-compare` to generate a hyperfine report in `benches/report.md`.\n\nPerformance on **1,000,000 random integers** (in-process timing):\n\n| Algorithm | Time | vs builtin |\n| :--- | :--- | :--- |\n| `smart` | 63 ms | **4.2x faster** |\n| `par_sort` | 66 ms | **4.0x faster** |\n| `radix` | 100 ms | **2.7x faster** |\n| `pdq` | 160 ms | **1.7x faster** |\n| `builtin` | 267 ms | 1.0x (baseline) |\n\n## Algorithm Complexity\n\n| Algorithm | Best | Average | Worst | Space | Stable |\n| :--- | :--- | :--- | :--- | :--- | :--- |\n| **`ordr.smart`** | O(n) | O(n log n) | O(n log n) | Varies | Varies* |\n| **`ordr.pdq`** | O(n) | O(n log n) | O(n log n) | O(log n) | No |\n| **`ordr.tim`** | O(n) | O(n log n) | O(n log n) | O(n) | Yes |\n| **`ordr.intro`** | O(n log n) | O(n log n) | O(n log n) | O(log n) | No |\n| **`ordr.radix`** | O(nk) | O(nk) | O(nk) | O(n+k) | Yes |\n| **`ordr.par_sort`** | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |\n| **`ordr.par_sort_unstable`** | O(n log n) | O(n log n) | O(n log n) | O(log n) | No |\n\n*\\*`ordr.smart` may choose a stable or unstable algorithm depending on the data.*\n\n## Architecture\n\n`ordr` is built with a modular architecture that separates the high-performance Rust core from the ergonomic Python API.\n\n- **Rust Core**: Found in `src/`, containing the implementation of all sorting algorithms and the analysis engine.\n- **Adaptive Engine**: Located in `src/adaptive/`, responsible for algorithmic dispatch with sampling-based analysis.\n- **Python Bridge**: NumPy `PyArray1` bindings in `src/lib.rs` and the `python/ordr/` package. Data flows as `list → np.ndarray → Rust in-place sort → list`.\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to get started.\n\n## License\n\n`ordr` is licensed under the MIT License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammersd21%2Fordr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrammersd21%2Fordr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammersd21%2Fordr/lists"}