remove array_multisort and convert array_multisortN to use inout
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / usort_variation7.php
blob593f0edf65394e44580f9d560e60a2007d44f67e
1 <?hh
2 /* Prototype : bool usort(&array $array_arg, string $cmp_function)
3 * Description: Sort an array by values using a user-defined comparison function
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass an anonymous comparison function as $cmp_function argument to test behaviour()
9 */
10 <<__EntryPoint>> function main(): void {
11 echo "*** Testing usort() : usage variation ***\n";
13 $cmp_function = ($value1, $value2) ==> { if($value1 == $value2) {return 0;} else if($value1 > $value2) {return 1;} else{return -1;} };
14 $cmp_function_ref = (&$value1, &$value2) ==> { if($value1 == $value2) {return 0;} else if($value1 > $value2) {return 1;} else{return -1;} };
16 $array_arg = array(0 => 100, 1 => 3, 2 => -70, 3 => 24, 4 => 90);
18 echo "\n-- Anonymous 'cmp_function' with parameters passed by value --\n";
19 var_dump( usort(&$array_arg, $cmp_function ) );
20 var_dump($array_arg);
22 $array_arg = array("b" => "Banana", "m" => "Mango", "a" => "Apple", "p" => "Pineapple");
24 echo "\n-- Anonymous 'cmp_function' with parameters passed by reference --\n";
25 var_dump( usort(&$array_arg, $cmp_function_ref) );
26 var_dump($array_arg);
27 echo "===DONE===\n";