ArrayObject uasort() Function in PHP Last Updated : 26 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The uasort() function of the ArrayObject class in PHP is used to sort values of an ArrayObject according to a user defined comparison function. The function compares and arranges the values present in the ArrayObject according to the given comparison function. This method does not affects the key-value associations. Syntax: void uasort($comparator) Parameters: This function accepts a single parameter $comparator which is the user defined comparison function. This comparison function in turn accepts two arguments which are the values of the ArrayObject 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 returns any value. Below program illustrate the above function: php <?php // PHP program to illustrate the // uasort() function $arr = array("Welcome"=>"1", "to" => "2", "GfG" => "3"); // Create array object $arrObject = new ArrayObject($arr); // Declare a comparison function to sort // values in descending order function comparison($val1, $val2) { if ($val1 == $val2) { return 0; } else if($val1 > $val2) return -1; else return 1; } $arrObject->uasort('comparison'); // Print the sorted ArrayObject print_r($arrObject); ?> Output: ArrayObject Object ( [storage:ArrayObject:private] => Array ( [GfG] => 3 [to] => 2 [Welcome] => 1 ) ) Reference: http://php.net/manual/en/arrayobject.uasort.php Comment More infoAdvertise with us Next Article ArrayObject uasort() Function in PHP gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ArrayObject Similar Reads ArrayObject uksort() Function in PHP The uksort() function of the ArrayObject class in PHP is used to sort the entries present in the ArrayObject according to the keys following a user-defined function. They key-value mapping is preserved after sorting the ArrayObject. Syntax: void uksort($comparator) Parameters: This function accepts 2 min read ArrayObject ksort() Function in PHP The ksort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject according to the keys. This function does not affects the association of the keys with the values, it just sorts the entries of the ArrayObject according to the Keys. Syntax: void ksort() Parameters: 2 min read ArrayObject natsort() Function in PHP The natsort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject following a natural order sorting algorithm. The natsort() function is used to sort alphanumeric strings in a order a normal human being would do. Syntax: void natsort() Parameters: This function d 2 min read ArrayObject asort() Function in PHP The asort() function of the ArrayObject class in PHP is used to sort all of the entries of the ArrayObject according to the values. The elements are arranged according to the values keeping the maintaining the association of the keys with the value. Syntax: void asort() Parameters: This function doe 1 min read 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. Syntax: void ArrayIterator::uasort( callable $cmp_function ) Parameters: This function accepts a single parameter $cmp_f 2 min read PHP | ArrayObject unserialize() Function The ArrayObject::unserialize() function is an inbuilt function in PHP which is used to unserializes the serialized ArrayObject. Syntax: void ArrayObject::unserialize( string $serialized ) Parameters: This function accepts single parameter $serialized which holds the serialized ArrayObject. Return Va 1 min read ArrayObject natcasesort() Function in PHP The natcasesort() function of the ArrayObject class in PHP is used to sort the elements of the ArrayObject following a natural order case sensitive sorting algorithm. Natural ordering means to arrange the elements in a order a normal human being would do. Syntax: void natcasesort() Parameters: This 2 min read PHP | ArrayIterator uksort() Function The ArrayIterator::uksort() function is an inbuilt function in PHP which is used to sort the keys by using a user-defined comparison function. Syntax: void ArrayIterator::uksort( callable $cmp_function ) Parameters: This function accepts single parameter $cmp_function which holds the user defined co 2 min read ArrayObject offsetGet() Function in PHP The offsetGet() function of the ArrayObject class in PHP is used to get the value present at a specific index at the ArrayObject. Syntax: mixed offsetGet($index) Parameters: This function accepts a single parameter $index for which corresponding value will be returned. Return Value: This function re 1 min read PHP array_intersect_uassoc() Function The array_intersect_uassoc() function is an inbuilt function in PHP. It is used to compare key and values of two or more arrays by using a user-defined comparison function and return the matches.The comparison function returns an integer equal to, greater than, or less than zero. If the first argume 6 min read Like