Download the PHP package tsoffereins/number-sorter without Composer
On this page you can find all versions of the php package tsoffereins/number-sorter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tsoffereins/number-sorter
More information about tsoffereins/number-sorter
Files in tsoffereins/number-sorter
Package number-sorter
Short Description A PHP library that helps you sort your numbers alphabetically.
License MIT
Homepage https://github.com/tsoffereins/number-sorter
Informations about the package number-sorter
Number sorter
With this library you can finally sort your list of numbers the way you always wanted: alphabetically.
Installation
You can install the NumberSorter through composer:
This library requires PHP 5.6 or higher in order to work.
Usage
Sorting a list of number alphabetically is easy as 1 3 2:
Numeric list
The input list must be an array of only numeric values. This includes any value that would make is_numeric()
return true. See php.net for more on that.
If you pass a non numeric value a TypeError
will be thrown.
Language
By default numbers are sorted alphabetically in English, but if you'd like to sort in another language you can pass it to the constructor:
The NumberSorter library relies on the package kwn/number-to-words
for translating numbers into words. Take a look at
their documentation for the available locales.
Immutability
Passing an array by reference and sorting its contents, like PHP's sort()
function does, might have been OK in the
nineties, but proper code should limit side effects. Therefore, the NumberSorter does not alter the input array but
returns a new array with the same numbers sorted alphabetically.
Support
Are you kidding me?!