convert ***sort builtins to use inout instead of references
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / asort_variation10.php
blob98d98feeaad96d4a43a89ecb75c9f9bcdeba0666
1 <?hh
2 /* Prototype : bool asort ( array &$array [, int $sort_flags] )
3 * Description: Sort an array and maintain index association.
4 Elements will be arranged from lowest to highest when this function has completed.
5 * Source code: ext/standard/array.c
6 */
8 /*
9 * testing asort() by providing different octal array for $array argument with following flag values
10 * 1.flag value as defualt
11 * 2.SORT_REGULAR - compare items normally
12 * 3.SORT_NUMERIC - compare items numerically
14 <<__EntryPoint>> function main(): void {
15 echo "*** Testing asort() : usage variations ***\n";
17 // an array contains unsorted octal values
18 $unsorted_oct_array = array (
19 01235 => 01235, 0321 => 0321, 0345 => 0345, 066 => 066, 0772 => 0772,
20 077 => 077, -066 => -066, -0345 => -0345, 0 => 0
23 echo "\n-- Testing asort() by supplying octal value array, 'flag' value is defualt --\n";
24 $temp_array = $unsorted_oct_array;
25 var_dump( asort(inout $temp_array) ); // expecting : bool(true)
26 var_dump($temp_array);
28 echo "\n-- Testing asort() by supplying octal value array, 'flag' value is SORT_REGULAR --\n";
29 $temp_array = $unsorted_oct_array;
30 var_dump( asort(inout $temp_array, SORT_REGULAR) ); // expecting : bool(true)
31 var_dump($temp_array);
33 echo "\n-- Testing asort() by supplying octal value array, 'flag' value is SORT_NUMERIC --\n";
34 $temp_array = $unsorted_oct_array;
35 var_dump( asort(inout $temp_array, SORT_NUMERIC) ); // expecting : bool(true)
36 var_dump($temp_array);
38 echo "Done\n";