ArrayIterator::uasort

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

ArrayIterator::uasortSort with a user-defined comparison function and maintain index association

說明

public ArrayIterator::uasort(callable $callback): bool

This method sorts the elements such that indices maintain their correlation with the values they are associated with, using a user-defined comparison function.

注意:

如果兩個(gè)成員完全相同,那么它們將保持原來的順序。 在 PHP 8.0.0 之前,它們?cè)谂判驍?shù)組中的相對(duì)順序是未定義的。

參數(shù)

callback

在第一個(gè)參數(shù)小于,等于或大于第二個(gè)參數(shù)時(shí),該比較函數(shù)必須相應(yīng)地返回一個(gè)小于,等于或大于 0 的整數(shù)。

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

返回值

總是返回 true 。

參見