2017 © Pedro Peláez
 

library numbered-string-order

Sort a string array based on the included numbers naturally.

image

awssat/numbered-string-order

Sort a string array based on the included numbers naturally.

  • Sunday, November 26, 2017
  • by if4lcon
  • Repository
  • 2 Watchers
  • 3 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

numberedStringOrder

Latest Version on Packagist StyleCI Build Status, (*1)

Sort an array of strings based on the included numbers naturally. An alternative to PHP built-in natsort function that's actually work., (*2)

Install

Via Composer, (*3)

``` bash $ composer require awssat/numbered-string-order, (*4)


## Usage #### Sort ```php //if you are using laravel, then instead use: //$numberedStringOrder = app(Awssat\numberedStringOrder\numberedStringOrder::class); $numberedStringOrder = new numberedStringOrder(); $numberedStringOrder->sort([ 'episode 5', 'episode50', '499', 'episode1', 'episode two hundred', 'episode one', 'episode two', 'episode eleven', 'episode three' ]); >> output: [ "episode1", "episode one", "episode two", "episode three", "episode 5", "episode eleven", "episode50", "episode two hundred", 499, ]

If you ask why not use the built-in function (natsort), then see the natsort output of the same example above to know why:, (*5)

 //output of built-in function natsor(): 🤨
 [
     "499",
     "episode1",
     "episode 5",
     "episode50",
     "episode eleven",
     "episode one",
     "episode three",
     "episode two",
     "episode two hundred",
   ]
 ```


 #### Get the numbers
If you want to use our internal numbers extracting method

```php
$numberedStringOrder->getNumbers(['2digits', 'text1', 'three3', 'two cars', 'blank']);

>> output:
[
     "2digits" => 2,
     "text1" => "1",
     "three3" => "3",
     "two cars" => 2,
     "blank" => "blank",
]

Convert words to numbers

This package can also be helpful if you want to convert numerical words to numbers, (*6)

new numberedStringOrder();
$numberedStringOrder->englishWordsToNumbers('one hundred twenty-three thousand four hundred fifty-six');
>> output: 123456

//to get arabic words to number use: arabicWordsToNumbers(...)

Test

composer test

Currently, it supports English and Arabic., (*7)

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

26/11 2017

dev-master

9999999-dev https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Awssat

php array sort

26/11 2017

dev-analysis-qxKYQ3

dev-analysis-qxKYQ3 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Awssat

php array sort

16/11 2017

1.0.8

1.0.8.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Awssat

php array sort

16/11 2017

1.0.7

1.0.7.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Awssat

php array sort

15/11 2017

1.0.6

1.0.6.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Awssat

php array sort

15/11 2017

1.0.5

1.0.5.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Awssat

php array sort

15/11 2017

1.0.4

1.0.4.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

by Awssat

php array sort

15/11 2017

1.0.3

1.0.3.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

by Awssat

php array sort

15/11 2017

1.0.2

1.0.2.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

by Awssat

php array sort

15/11 2017

1.0.1

1.0.1.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

by Awssat

php array sort

15/11 2017

1

1.0.0.0 https://github.com/Awssat/numberedStringOrder

Sort a string array based on the included numbers naturally.

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

by Awssat

php array sort