convert ***sort builtins to use inout instead of references
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / asort_variation6.php
blobc1074f4fc0dd86f945072a47d98116ec429ab7b8
1 <?hh
2 /* Prototype : bool asort ( array &$array [, int $asort_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 hexa-decimal array for $array argument with following flag values
10 * flag value as defualt
11 * SORT_REGULAR - compare items normally
12 * SORT_NUMERIC - compare items numerically
14 <<__EntryPoint>> function main(): void {
15 echo "*** Testing asort() : usage variations ***\n";
17 // an array contains unsorted hexadecimal values
18 // There are multiple keys which are duplicate and the later should be picked
19 $unsorted_hex_array = array ( 0x1AB => 0x1AB, 0xFFF => 0xFFF, 0xF => 0xF, 0xFF => 0xFF, 0x2AA => 0x2AA, 0xBB => 0xBB,
20 0x1ab => 0x1ab, 0xff => 0xff, -0xff => -0xFF, 0 => 0, -0x2aa => -0x2aa
23 echo "\n-- Testing asort() by supplying hexadecimal value array, 'flag' value is defualt --\n";
24 $temp_array = $unsorted_hex_array;
25 var_dump(asort(inout $temp_array) ); // expecting : bool(true)
26 var_dump($temp_array);
28 echo "\n-- Testing asort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR --\n";
29 $temp_array = $unsorted_hex_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 hexadecimal value array, 'flag' value is SORT_NUMERIC --\n";
34 $temp_array = $unsorted_hex_array;
35 var_dump(asort(inout $temp_array, SORT_NUMERIC) ); // expecting : bool(true)
36 var_dump($temp_array);
38 echo "Done\n";