PHP | ArrayIterator uasort() Function
The ArrayIterator::uasort() function is an inbuilt function in PHP which is used to sort the element using a user-defined comparison function and maintain their index association.
void ArrayIterator::uasort( callable $cmp_function )
Parameters: This function accepts a single parameter $cmp_function which is the user-defined comparison function. This comparison function accepts two parameters which are the values of the ArrayIterator and returns less than, equals to or greater than zero if the first argument is less than, equals to or greater than zero respectively.
Return Value: This function does not return any value.
Below programs illustrate the ArrayIterator::uasort() function in PHP:
ArrayIterator Object ( [storage:ArrayIterator:private] => Array ( [e] => 1 [b] => 2 [a] => 4 [d] => 6 [g] => 8 [f] => 9 ) )
ArrayIterator Object ( [storage:ArrayIterator:private] => Array ( [b] => for [e] => Science [f] => Portal [a] => Geeks => Geeks [d] => Computer ) )