convert ***sort builtins to use inout instead of references
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / sort_variation8.php
blobe12795fb38085e4628bbbaea29c7ead7deb278cc
1 <?hh
2 /* Prototype : bool sort ( array &$array [, int $sort_flags] )
3 * Description: This function sorts an array.
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 sort() by providing arrays contains sub arrays for $array argument with flowing flag values
10 * flag value as defualt
11 * SORT_REGULAR - compare items normally
13 <<__EntryPoint>> function main(): void {
14 echo "*** Testing sort() : usage variations ***\n";
16 // array of arrays
17 $various_arrays = array (
18 // null array
19 array(),
21 // array contains null sub array
22 array( array() ),
24 // array of arrays along with some values
25 array(44, 11, array(64, 61) ),
27 // array containing sub arrays
28 array(array(33, -5, 6), array(11), array(22, -55), array() )
32 $count = 1;
33 echo "\n-- Testing sort() by supplying various arrays containing sub arrays --\n";
35 // loop through to test sort() with different arrays
36 foreach ($various_arrays as $array) {
38 echo "\n-- Iteration $count --\n";
39 // testing sort() function by supplying different arrays, flag value is defualt
40 echo "- With Defualt sort flag -\n";
41 $temp_array = $array;
42 var_dump(sort(inout $temp_array) );
43 var_dump($temp_array);
45 // testing sort() function by supplying different arrays, flag value = SORT_REGULAR
46 echo "- Sort flag = SORT_REGULAR -\n";
47 $temp_array = $array;
48 var_dump(sort(inout $temp_array, SORT_REGULAR) );
49 var_dump($temp_array);
50 $count++;
53 echo "Done\n";