{"id":21586039,"url":"https://github.com/magiclen/alphanumeric-sort","last_synced_at":"2025-07-02T23:33:19.865Z","repository":{"id":57485087,"uuid":"146553251","full_name":"magiclen/alphanumeric-sort","owner":"magiclen","description":"This crate can help you sort order for files and folders whose names contain numerals.","archived":false,"fork":false,"pushed_at":"2024-05-01T12:59:03.000Z","size":53,"stargazers_count":21,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-11T04:21:59.951Z","etag":null,"topics":["rust","sort"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/magiclen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2018-08-29T06:09:07.000Z","updated_at":"2025-04-20T04:22:16.000Z","dependencies_parsed_at":"2024-05-01T14:32:56.169Z","dependency_job_id":"24a6da21-a272-44b7-b9ab-a37152dd5135","html_url":"https://github.com/magiclen/alphanumeric-sort","commit_stats":{"total_commits":54,"total_committers":3,"mean_commits":18.0,"dds":0.05555555555555558,"last_synced_commit":"2b17482eb1a7ad2c5c0c043b089e0a2d48bc3d6d"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/magiclen/alphanumeric-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Falphanumeric-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Falphanumeric-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Falphanumeric-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Falphanumeric-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/alphanumeric-sort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Falphanumeric-sort/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263233345,"owners_count":23434838,"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":["rust","sort"],"created_at":"2024-11-24T15:12:28.792Z","updated_at":"2025-07-02T23:33:19.784Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Alphanumeric Sort\n====================\n\n[![CI](https://github.com/magiclen/alphanumeric-sort/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/alphanumeric-sort/actions/workflows/ci.yml)\n\nThis crate can help you sort order for files and folders whose names contain numerals.\n\n## Motives and Examples\n\nWith the Rust native `sort` method, strings and paths are arranged into lexicographical order. In some cases, it is not so intuitive. For example, there are screen snap shots named by **shot-%N** like **shot-2**, **shot-1**, **shot-11**. After a lexicographical sorting, they will be ordered into **shot-1**, **shot-11**, **shot-2**. However, we would prefer **shot-1**, **shot-2**, **shot-11** mostly.\n\n```rust\nlet mut names = [\"shot-2\", \"shot-1\", \"shot-11\"];\n\nnames.sort();\n\nassert_eq!([\"shot-1\", \"shot-11\", \"shot-2\"], names);\n```\n\nThus, in this kind of case, an alphanumeric sort might come in handy.\n\n```rust\nlet mut names = [\"shot-2\", \"shot-1\", \"shot-11\"];\n\nalphanumeric_sort::sort_str_slice(\u0026mut names);\n\nassert_eq!([\"shot-1\", \"shot-2\", \"shot-11\"], names);\n```\n\n```rust\nuse std::path::Path;\n\nlet mut paths = [Path::new(\"shot-2\"), Path::new(\"shot-1\"), Path::new(\"shot-11\")];\n\nalphanumeric_sort::sort_path_slice(\u0026mut paths);\n\nassert_eq!([Path::new(\"shot-1\"), Path::new(\"shot-2\"), Path::new(\"shot-11\")], paths);\n```\n\n## About the `compare_*` Functions and the `sort_*` Functions\n\nTo sort a slice, the code can also be written like,\n\n```rust\nuse std::path::Path;\n\nlet mut paths = [Path::new(\"shot-2\"), Path::new(\"shot-1\"), Path::new(\"shot-11\")];\n\npaths.sort_by(|a, b| alphanumeric_sort::compare_path(a, b));\n\nassert_eq!([Path::new(\"shot-1\"), Path::new(\"shot-2\"), Path::new(\"shot-11\")], paths);\n```\n\nBut it is not recommended because the `compare_*` functions try to convert data (e.g `Path`, `CStr`) to `\u0026str` every time in its execution and thus they are slower than the `sort_*` functions when sorting a slice.\n\n## Version `1.3` to `1.4`\n\nNo breaking change in API is made, though the order has some changes.\n\n* `\"0001\"` is greater than `\"001\"` instead of being equal.\n* `\"中\"` is greater than `\"1\"` instead of being less. `\"第1章\"` is still less than `\"第1-2章\"`, even though `\"章\"` is greater than `\"-\"`.\n\n## No Std\n\nDisable the default features to compile this crate without std.\n\n```toml\n[dependencies.alphanumeric-sort]\nversion = \"*\"\ndefault-features = false\n```\n\n## Benchmark\n\n```bash\ncargo bench\n```\n\n## Crates.io\n\nhttps://crates.io/crates/alphanumeric-sort\n\n## Documentation\n\nhttps://docs.rs/alphanumeric-sort\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Falphanumeric-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Falphanumeric-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Falphanumeric-sort/lists"}