PHP - sort
Trieda
Metóda - sort
(PHP 4, PHP 5, PHP 7)
Sorts values in an array from the lowest to the highest.
The function re-indexes the array. More precisely, it removes the keys and creates new ones.
Internally, the sort is implemented by the "Quick sort algorithm":https://www.ict.social/…ting-numbers.
Procedurálne
- function sort (array &$array, int $sort_flags = SORT_REGULAR) : bool
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| &$array | array | The input array. | |
| $sort_flags | int | SORT_REGULAR | The optional parameter. We can use the following flags:
|
Mávratovej hodnoty
Vracia: bool
TRUE or FALSE depending on whether sorting was successful or not.
Príklady
<?php
$array = [5, 3, 2, 5, 6, 1];
sort($array);
print_r($array);
