(PHP 5 >= 5.2.0, PHP 7, PHP 8)
ArrayIterator::uasort — Sort with a user-defined comparison function and maintain index association
This method sorts the elements such that indices maintain their correlation with the values they are associated with, using a user-defined comparison function.
Nota:
Se dois elementos são comparados como iguais, eles mantêm sua ordem original. Antes do PHP 8.0.0, sua ordem relativa no array ordenado era indefinida.
callback
A função de comparação deve retornar um inteiro menor que, igual ou maior que zero se o primeiro argumento for considerado respectivamente menor que, igual ou maior que o segundo.
Returning non-integer values from the comparison
function, such as float, will result in an internal cast to
int of the callback's return value. So values such as
0.99
and 0.1
will both be cast to an
integer value of 0
, which will compare such values as equal.
Sempre retorna true
.
Versão | Descrição |
---|---|
8.2.0 |
O tipo do retorno agora é true ; anteriormente, era bool.
|