ArrayObject asort() Function in PHP Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 does not accepts any parameters. Return Value: This function does not returns any value. Below programs illustrate the above function: Program 1: php <?php // PHP program to illustrate the // asort() function $arr = array("a" => "geeks", "b" => "are", "c" => "awesome"); $arrObject = new ArrayObject($arr); // Sort the ArrayObject $arrObject->asort(); print_r($arrObject); ?> Output: ArrayObject Object ( [storage:ArrayObject:private] => Array ( [b] => are [c][/c] => awesome [a] => geeks ) ) Program 2: php <?php // PHP program to illustrate the // asort() function $arr = array("a" => "welcome", "b" => "to", "c" => "gfg"); $arrObject = new ArrayObject($arr); // Sort the ArrayObject $arrObject->asort(); print_r($arrObject); ?> Output: ArrayObject Object ( [storage:ArrayObject:private] => Array ( [c][/c] => gfg [b] => to [a] => welcome ) ) Reference: https://www.php.net/manual/en/arrayobject.asort.php Comment More infoAdvertise with us Next Article PHP | ArrayObjects::_construct() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-array PHP-function PHP-ArrayObject +1 More Similar Reads 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 PHP | ArrayObjects::_construct() Function The ArrayObjects class allows objects to work as arrays. The ArrayObjects::_construct() is an in built PHP function to construct a new array object. Syntax: public ArrayObject::__construct ($input = array(), int $flags = 0, string $iterator_class = "ArrayIterator") Parameters: This function accepts 2 min read ArrayObject uasort() Function in PHP 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-va 2 min read 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 PHP | ArrayIterator asort() Function The ArrayIterator::asort() function is an inbuilt function in PHP which is used to sort the array values. Syntax: void ArrayIterator::asort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the ArrayIter 1 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 Like