The last post was about posting too but there I presented a general, well known sorting algorithm(Bubble Sort) that sorts a string of numbers.
PHP has a simple function that does a lot of things in the sorting world but comparing to Bubble Sort, You don't need to see and understand the source code.
The function looks like this:
array_multisort();
and it can sort 1 or even 2 dimensional arrays....
you can use it by giving values like: the array, sorting order, sorting type.
array_multisort($array,sorting order, sorting type);
and it can sort 1 or even 2 dimensional arrays....
you can use it by giving values like: the array, sorting order, sorting type.
array_multisort($array,sorting order, sorting type);
The array option is recommended but the other 2 are optional....
For the sorting order, you have the following options:
For the sorting order, you have the following options:
- SORT_ASC - sort in descending order (ex: from A to Z)
- SORT_DESC - sort in descending order (ex: from Z to A)
- SORT_REGULAR - This option compares elements in a normal way
- SORT_NUMERIC - This option compares elements as numeric values
- SORT_STRING - This option compares elements as string values
That's about it... You just call the function. and set the objects. It does everything...FAST MAGIC :)
No comments:
Post a Comment