PHP | collator_asort() Function Last Updated : 19 May, 2022 Comments Improve Suggest changes Like Article Like Report The collator_asort() function is an inbuilt function in PHP which is used to sort array maintaining the index association. This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. The array elements are sorted according to current locale rules. Syntax: Procedural style:bool collator_asort( $coll, &$arr, $sort_flag )Object oriented style:public bool Collator::asort( &$arr, $sort_flag ) Parameters: This function accepts three parameters as mentioned above and described below: $coll: This parameter is used as collator object.$arr: This parameter contains the array of strings which need to sort.$sort_flag: It is optional parameter which is used to define the sorting method, one of the following:Collator::SORT_REGULAR: It compare items normally. It is the default sorting.Collator::SORT_NUMERIC: It compare items numerically.Collator::SORT_STRING: It compare items as strings. Return Value: This function returns True on success or False on failure. Below programs illustrate the collator_asort() function in PHP: Program 1: php <?php $coll = collator_create( 'en_US' ); $arr = array( 'A' => '30', 'B' => '48', 'C' => '9', 'D' => '60' ); // Sort array according to its numeral value collator_asort( $coll, $arr, Collator::SORT_NUMERIC ); var_export( $arr ); ?> Output:array ( 'C' => '9', 'A' => '30', 'B' => '48', 'D' => '60', ) Program 2: php <?php $coll = collator_create( 'en_US' ); $arr = array( 'A' => '30', 'B' => '48', 'C' => '9', 'D' => '60' ); // Sort array according to its string value collator_asort( $coll, $arr, Collator::SORT_STRING ); var_export( $arr ); ?> Output:array ( 'A' => '30', 'B' => '48', 'D' => '60', 'C' => '9', ) Related Articles: PHP | uasort() FunctionPHP | rsort() Function Reference: http://php.net/manual/en/collator.asort.php Comment More infoAdvertise with us Next Article PHP | collator_asort() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP | asort() Function The asort() function is an inbuilt function in PHP which is used to sort an array according to values. It sorts in a way that relation between indices and values is maintained. By default it sorts in ascending order of values. Syntax: bool asort( $array, $sorting_type ) Parameters: This function acc 3 min read PHP | collator_sort() Function The collator_sort() function is an inbuilt function in PHP which is used to sort an array using specified collator. This function returns True on success or False on failure. Syntax: Procedural style: bool collator_sort( $coll, $arr, $sort_flag ) Object oriented style: bool Collator::sort( $arr, $so 2 min read PHP arsort() Function The arsort() in PHP is used to sort an array according to values. It sorts in a way that relation between indices and values is maintained. By default it sorts in descending order of values. Syntax: bool arsort( $array, $sorting_type ) Parameters: This function accepts two parameters as mentioned ab 2 min read PHP | Collator create() Function The Collator::create() function is an inbuilt function in PHP which is used to create a new collector. Syntax: Object oriented style: Collator Collator::create( $locale ) Procedural style: Collator collator_create( $locale ) Parameters: This function accepts single parameter $locale which holds the 1 min read PHP | collator_compare() Function The collator_compare() function is an inbuilt function in PHP which is used to compare two Unicode strings according to collation rules. Syntax: Procedural style: int collator_compare( $coll, $str1, $str2 ) Object oriented style: int Collator::compare( $str1, $str2 ) Parameters: This function accept 2 min read Like