{"id":21569199,"url":"https://github.com/awssat/numbered-string-order","last_synced_at":"2025-07-20T01:07:09.225Z","repository":{"id":62490322,"uuid":"110764857","full_name":"awssat/numbered-string-order","owner":"awssat","description":"🔢  Sort an array of strings based on the included numbers naturally.","archived":false,"fork":false,"pushed_at":"2019-07-15T11:45:58.000Z","size":26,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T14:17:15.066Z","etag":null,"topics":["arabic","array","episodes","natsort","natural-sort","order","orderby","php","sort","sorting-algorithms","string"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/awssat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-15T01:02:24.000Z","updated_at":"2022-11-18T13:07:03.000Z","dependencies_parsed_at":"2022-11-02T09:31:26.230Z","dependency_job_id":null,"html_url":"https://github.com/awssat/numbered-string-order","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/awssat/numbered-string-order","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fnumbered-string-order","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fnumbered-string-order/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fnumbered-string-order/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fnumbered-string-order/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awssat","download_url":"https://codeload.github.com/awssat/numbered-string-order/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awssat%2Fnumbered-string-order/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266052545,"owners_count":23869476,"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":["arabic","array","episodes","natsort","natural-sort","order","orderby","php","sort","sorting-algorithms","string"],"created_at":"2024-11-24T11:07:22.010Z","updated_at":"2025-07-20T01:07:09.202Z","avatar_url":"https://github.com/awssat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# numberedStringOrder\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/awssat/numbered-string-order.svg?style=flat-square)](https://packagist.org/packages/awssat/numbered-string-order)\n[![StyleCI](https://styleci.io/repos/110764857/shield?branch=master)](https://styleci.io/repos/110764857)\n[![Build Status](https://img.shields.io/travis/awssat/numberedStringOrder/master.svg?style=flat-square)](https://travis-ci.org/awssat/numberedStringOrder)\n\n\nSort an array of strings based on the included numbers naturally. An alternative to PHP built-in natsort function that's actually work.\n\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require awssat/numbered-string-order\n```\n\n## Usage\n\n\n#### Sort\n\n```php\n//if you are using laravel, then instead use:\n//$numberedStringOrder = app(Awssat\\numberedStringOrder\\numberedStringOrder::class);\n\n$numberedStringOrder = new numberedStringOrder();\n\n$numberedStringOrder-\u003esort([\n    'episode 5',\n    'episode50',\n    '499',\n    'episode1',\n    'episode two hundred',\n    'episode one',\n    'episode two',\n    'episode eleven',\n    'episode three'\n]);\n    \n\n\u003e\u003e output: \n[\n     \"episode1\",\n     \"episode one\",\n     \"episode two\",\n     \"episode three\",\n     \"episode 5\",\n     \"episode eleven\",\n     \"episode50\",\n     \"episode two hundred\",\n     499,\n]\n   \n```\n\n\nIf you ask why not use the built-in function (natsort), then see the natsort output of the same example above to know why:\n```php\n //output of built-in function natsor(): 🤨\n [\n     \"499\",\n     \"episode1\",\n     \"episode 5\",\n     \"episode50\",\n     \"episode eleven\",\n     \"episode one\",\n     \"episode three\",\n     \"episode two\",\n     \"episode two hundred\",\n   ]\n ```\n \n \n #### Get the numbers\nIf you want to use our internal numbers extracting method\n\n```php\n$numberedStringOrder-\u003egetNumbers(['2digits', 'text1', 'three3', 'two cars', 'blank']);\n\n\u003e\u003e output:\n[\n     \"2digits\" =\u003e 2,\n     \"text1\" =\u003e \"1\",\n     \"three3\" =\u003e \"3\",\n     \"two cars\" =\u003e 2,\n     \"blank\" =\u003e \"blank\",\n]\n```\n\n\n#### Convert words to numbers \nThis package can also be helpful if you want to convert numerical words to numbers \n\n```php\nnew numberedStringOrder();\n$numberedStringOrder-\u003eenglishWordsToNumbers('one hundred twenty-three thousand four hundred fifty-six');\n\u003e\u003e output: 123456\n\n//to get arabic words to number use: arabicWordsToNumbers(...)\n\n```\n\n\n\n## Test\n```bash\ncomposer test\n```\n\n\n\nCurrently, it supports English and Arabic.\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawssat%2Fnumbered-string-order","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawssat%2Fnumbered-string-order","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawssat%2Fnumbered-string-order/lists"}