ArrayIterator::uksort

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

ArrayIterator::uksortSort by keys using a user-defined comparison function

Descrição

public ArrayIterator::uksort(callable $callback): true

This method sorts the elements by keys using a user-supplied 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.

Parâmetros

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.

callback(mixed $a, mixed $b): int
Cuidado

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.

Valor Retornado

Sempre retorna true.

Changelog

Versão Descrição
8.2.0 O tipo do retorno agora é true; anteriormente, era bool.

Veja Também

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top