--- /dev/null
+--TEST--
+Test uasort() function : basic functionality
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+echo "*** Testing uasort() : basic functionality ***\n";
+
+// comparison function
+/* Prototype : int cmp(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+
+// Int array with default keys
+$int_values = array(1, 8, 9, 3, 2, 6, 7);
+echo "-- Numeric array with default keys --\n";
+var_dump( uasort($int_values, 'cmp') );
+var_dump($int_values);
+
+// String array with default keys
+$string_values = array("This", "is", 'a', "test");
+echo "-- String array with default keys --\n";
+var_dump( uasort($string_values, 'cmp') );
+var_dump($string_values);
+
+// Associative array with numeric keys
+$numeric_key_arg = array(1=> 1, 2 => 2, 3 => 7, 5 => 4, 4 => 9);
+echo "-- Associative array with numeric keys --\n";
+var_dump( uasort($numeric_key_arg, 'cmp') );
+var_dump($numeric_key_arg);
+
+// Associative array with string keys
+$string_key_arg = array('one' => 4, 'two' => 2, 'three' => 1, 'four' => 10);
+echo "-- Associative array with string keys --\n";
+var_dump( uasort($string_key_arg, 'cmp') );
+var_dump($string_key_arg);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : basic functionality ***
+-- Numeric array with default keys --
+bool(true)
+array(7) {
+ [0]=>
+ int(1)
+ [4]=>
+ int(2)
+ [3]=>
+ int(3)
+ [5]=>
+ int(6)
+ [6]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+}
+-- String array with default keys --
+bool(true)
+array(4) {
+ [0]=>
+ string(4) "This"
+ [2]=>
+ string(1) "a"
+ [1]=>
+ string(2) "is"
+ [3]=>
+ string(4) "test"
+}
+-- Associative array with numeric keys --
+bool(true)
+array(5) {
+ [1]=>
+ int(1)
+ [2]=>
+ int(2)
+ [5]=>
+ int(4)
+ [3]=>
+ int(7)
+ [4]=>
+ int(9)
+}
+-- Associative array with string keys --
+bool(true)
+array(4) {
+ ["three"]=>
+ int(1)
+ ["two"]=>
+ int(2)
+ ["one"]=>
+ int(4)
+ ["four"]=>
+ int(10)
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : basic functionality - duplicate values
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+echo "*** Testing uasort() : basic functionality with duplicate values ***\n";
+
+// comparison function
+/* Prototype : int cmp(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+
+// increasing values
+$int_values1 = array(1, 1, 2, 2, 3, 3);
+echo "-- Numeric array with increasing values --\n";
+var_dump( uasort($int_values1, 'cmp') );
+var_dump($int_values1);
+
+// decreasing values
+$int_values2 = array(3, 3, 2, 2, 1, 1);
+echo "-- Numeric array with decreasing values --\n";
+var_dump( uasort($int_values2, 'cmp') );
+var_dump($int_values2);
+
+// increasing and decreasing values
+$int_values3 = array(1, 2, 3, 3, 2, 1);
+echo "-- Numeric array with increasing and decreasing values --\n";
+var_dump( uasort($int_values3, 'cmp') );
+var_dump($int_values3);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : basic functionality with duplicate values ***
+-- Numeric array with increasing values --
+bool(true)
+array(6) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [3]=>
+ int(2)
+ [2]=>
+ int(2)
+ [5]=>
+ int(3)
+ [4]=>
+ int(3)
+}
+-- Numeric array with decreasing values --
+bool(true)
+array(6) {
+ [4]=>
+ int(1)
+ [5]=>
+ int(1)
+ [3]=>
+ int(2)
+ [2]=>
+ int(2)
+ [1]=>
+ int(3)
+ [0]=>
+ int(3)
+}
+-- Numeric array with increasing and decreasing values --
+bool(true)
+array(6) {
+ [5]=>
+ int(1)
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [4]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(3)
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : error conditions
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+echo "*** Testing uasort() : error conditions ***\n";
+
+// comparison function
+/* Prototype : int cmp(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else {
+ return -1;
+ }
+}
+
+// Initialize 'array_arg'
+$array_arg = array(0 => 1, 1 => 10, 2 => 'string', 3 => 3, 4 => 2, 5 => 100, 6 => 25);
+
+// With zero arguments
+echo "-- Testing uasort() function with Zero argument --\n";
+var_dump( uasort() );
+
+// With one more than the expected number of arguments
+echo "-- Testing uasort() function with more than expected no. of arguments --\n";
+$extra_arg = 10;
+var_dump( uasort($array_arg, 'cmp', $extra_arg) );
+
+// With one less than the expected number of arguments
+echo "-- Testing uasort() function with less than expected no. of arguments --\n";
+var_dump( uasort($array_arg) );
+
+// With non existent comparison function
+echo "-- Testing uasort() function with non-existent compare function --\n";
+var_dump( uasort($array_arg, 'non_existent') );
+
+// With non existent comparison function and extra arguemnt
+echo "-- Testing uasort() function with non-existent compare function and extra argument --\n";
+var_dump( uasort($array_arg, 'non_existent', $extra_arg) );
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : error conditions ***
+-- Testing uasort() function with Zero argument --
+
+Warning: Wrong parameter count for uasort() in %s on line %d
+NULL
+-- Testing uasort() function with more than expected no. of arguments --
+
+Warning: Wrong parameter count for uasort() in %s on line %d
+NULL
+-- Testing uasort() function with less than expected no. of arguments --
+
+Warning: Wrong parameter count for uasort() in %s on line %d
+NULL
+-- Testing uasort() function with non-existent compare function --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Testing uasort() function with non-existent compare function and extra argument --
+
+Warning: Wrong parameter count for uasort() in %s on line %d
+NULL
+Done
--- /dev/null
+--TEST--
+Test uasort() function : object functionality
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+ * Testing uasort() function with the array of objects
+ * array of objects which has only one member variable & more than one member variables
+ */
+
+echo "*** Testing uasort() : object functionality ***\n";
+
+// comparison function
+/* Prototype : int cmp(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value3
+ * Description : compares value1 and value2
+ */
+function simple_cmp($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+
+// comparison function for SimpleClass2 objects which has more than one members
+function multiple_cmp($value1, $value2)
+{
+ if($value1->getValue() == $value2->getValue())
+ return 0;
+ else if($value1->getValue() > $value2->getValue())
+ return 1;
+ else
+ return -1;
+}
+
+// Simple class with single member variable
+class SimpleClass1
+{
+ private $int_value;
+
+ public function __construct($value) {
+ $this->int_value = $value;
+ }
+}
+
+// Simple class with more than one member variables
+class SimpleClass2
+{
+ private $int_value;
+ protected $float_value;
+ public $string_value;
+ public function __construct($int, $float, $str) {
+ $this->int_value = $int;
+ $this->float_value = $float;
+ $this->string_value = $str;
+ }
+ public function getValue() {
+ return $this->int_value;
+ }
+}
+
+// array of SimpleClass objects with only one member
+$array_arg = array(
+ 0 => new SimpleClass1(10),
+ 1 => new SimpleClass1(1),
+ 2 => new SimpleClass1(100),
+ 3 => new SimpleClass1(50)
+);
+var_dump( uasort($array_arg, 'simple_cmp') );
+var_dump($array_arg);
+
+// array of SimpleClass objects having more than one members
+$array_arg = array(
+ 0 => new SimpleClass2(2, 3.4, "mango"),
+ 1 => new SimpleClass2(10, 1.2, "apple"),
+ 2 => new SimpleClass2(5, 2.5, "orange"),
+);
+var_dump( uasort($array_arg, 'multiple_cmp') );
+var_dump($array_arg);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : object functionality ***
+bool(true)
+array(4) {
+ [1]=>
+ object(SimpleClass1)#%d (1) {
+ ["int_value:private"]=>
+ int(1)
+ }
+ [0]=>
+ object(SimpleClass1)#%d (1) {
+ ["int_value:private"]=>
+ int(10)
+ }
+ [3]=>
+ object(SimpleClass1)#%d (1) {
+ ["int_value:private"]=>
+ int(50)
+ }
+ [2]=>
+ object(SimpleClass1)#%d (1) {
+ ["int_value:private"]=>
+ int(100)
+ }
+}
+bool(true)
+array(3) {
+ [0]=>
+ object(SimpleClass2)#%d (3) {
+ ["int_value:private"]=>
+ int(2)
+ ["float_value:protected"]=>
+ float(3.4)
+ ["string_value"]=>
+ string(5) "mango"
+ }
+ [2]=>
+ object(SimpleClass2)#%d (3) {
+ ["int_value:private"]=>
+ int(5)
+ ["float_value:protected"]=>
+ float(2.5)
+ ["string_value"]=>
+ string(6) "orange"
+ }
+ [1]=>
+ object(SimpleClass2)#%d (3) {
+ ["int_value:private"]=>
+ int(10)
+ ["float_value:protected"]=>
+ float(1.2)
+ ["string_value"]=>
+ string(5) "apple"
+ }
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : object functionality - sort diff. objects
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*
+
+/*
+ * This testcase tests uasort() functionality with differnt objects
+ * Objects of different classes:
+ * simple class,
+ * child class,
+ * empty class &
+ * static class
+ */
+
+echo "*** Testing uasort() : object functionality ***\n";
+
+// comparison function
+/* Prototype : int cmp_function(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp_function($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+
+
+// Simple class with single member variable
+class SimpleClass
+{
+ private $int_value;
+
+ public function __construct($value) {
+ $this->int_value = $value;
+ }
+
+}
+
+// Class without any member
+class EmptyClass
+{
+}
+
+// Class with static member
+class StaticClass
+{
+ public static $static_value;
+ public function __construct($value) {
+ StaticClass::$static_value = $value;
+ }
+}
+
+// Abstract class
+abstract class AbstractClass
+{
+ public $pub_value;
+ public abstract function abstractMethod();
+}
+
+// Child class extending abstract class
+class ChildClass extends AbstractClass
+{
+ public $child_value = 100;
+ public function abstractMethod() {
+ $pub_value = 5;
+ }
+ public function __construct($value) {
+ $this->child_value = $value;
+ }
+}
+
+// Testing uasort with StaticClass objects as elements of 'array_arg'
+echo "-- Testing uasort() with StaticClass objects --\n";
+$array_arg = array(
+ 0 => new StaticClass(20),
+ 1 => new StaticClass(50),
+ 2 => new StaticClass(15),
+ 3 => new StaticClass(70),
+);
+var_dump( uasort($array_arg, 'cmp_function') );
+var_dump($array_arg);
+
+// Testing uasort with EmptyClass objects as elements of 'array_arg'
+echo "-- Testing uasort() with EmptyClass objects --\n";
+$array_arg = array(
+ 0 => new EmptyClass(),
+ 1 => new EmptyClass(),
+ 2 => new EmptyClass(),
+ 3 => new EmptyClass(),
+);
+var_dump( uasort($array_arg, 'cmp_function') );
+var_dump($array_arg);
+
+// Testing uasort with ChildClass objects as elements of 'array_arg'
+echo "-- Testing uasort() with ChildClass objects --\n";
+$array_arg = array(
+ 0 => new ChildClass(20),
+ 1 => new ChildClass(500),
+ 2 => new ChildClass(15),
+ 3 => new ChildClass(700),
+);
+var_dump( uasort($array_arg, 'cmp_function') );
+var_dump($array_arg);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : object functionality ***
+-- Testing uasort() with StaticClass objects --
+bool(true)
+array(4) {
+ [3]=>
+ object(StaticClass)#%d (0) {
+ }
+ [2]=>
+ object(StaticClass)#%d (0) {
+ }
+ [1]=>
+ object(StaticClass)#%d (0) {
+ }
+ [0]=>
+ object(StaticClass)#%d (0) {
+ }
+}
+-- Testing uasort() with EmptyClass objects --
+bool(true)
+array(4) {
+ [3]=>
+ object(EmptyClass)#%d (0) {
+ }
+ [2]=>
+ object(EmptyClass)#%d (0) {
+ }
+ [1]=>
+ object(EmptyClass)#%d (0) {
+ }
+ [0]=>
+ object(EmptyClass)#%d (0) {
+ }
+}
+-- Testing uasort() with ChildClass objects --
+bool(true)
+array(4) {
+ [2]=>
+ object(ChildClass)#%d (2) {
+ ["child_value"]=>
+ int(15)
+ ["pub_value"]=>
+ NULL
+ }
+ [0]=>
+ object(ChildClass)#%d (2) {
+ ["child_value"]=>
+ int(20)
+ ["pub_value"]=>
+ NULL
+ }
+ [1]=>
+ object(ChildClass)#%d (2) {
+ ["child_value"]=>
+ int(500)
+ ["pub_value"]=>
+ NULL
+ }
+ [3]=>
+ object(ChildClass)#%d (2) {
+ ["child_value"]=>
+ int(700)
+ ["pub_value"]=>
+ NULL
+ }
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - unexpected values for 'array_arg' argument
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing uasort() function by passing different scalar/nonscalar values as 'array_arg' argument
+*/
+
+echo "*** Testing uasort() : unexpected values for 'array_arg' ***\n";
+
+// Comparison function
+/* Prototype : int cmp_function(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp_function($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else {
+ return -1;
+ }
+}
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get resource variable
+$fp = fopen(__FILE__,'r');
+
+//array of values to iterate over
+$input_values = array(
+
+ // int data
+/*1*/ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+/*5*/ 10.5,
+ -10.5,
+ 10.1234567e8,
+ 10.7654321E-8,
+ .5,
+
+ // null data
+/*10*/ NULL,
+ null,
+
+ // boolean data
+/*12*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*16*/ "",
+ '',
+
+ // string data
+/*18*/ "string",
+ 'string',
+
+ // resource data
+/*20*/ $fp,
+
+ // undefined data
+ @$undefined_var,
+
+ // unset data
+/*22*/ @$unset_var,
+);
+
+// loop through each value of input_values
+for($count = 0; $count < count($input_values); $count++) {
+ echo "-- Iteration ".($count + 1)." --\n";
+ var_dump( uasort($input_values[$count], 'cmp_function') );
+};
+
+//closing resource
+fclose($fp);
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : unexpected values for 'array_arg' ***
+-- Iteration 1 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 7 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 8 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 9 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 10 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 11 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 12 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 13 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 14 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 15 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 16 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 17 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 18 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 19 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 20 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 21 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+-- Iteration 22 --
+
+Warning: uasort(): The argument should be an array in %s on line %d
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - sort array with reference variables
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing uasort() with 'array_arg' containing different reference variables
+*/
+
+// comparision function
+/* Prototype : int cmp_function(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp_function($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else {
+ return -1;
+ }
+}
+
+echo "*** Testing uasort() : 'array_arg' with elements as reference ***\n";
+
+// different variables which are used as elements of 'array_arg'
+$value1 = -5;
+$value2 = 100;
+$value3 = 0;
+$value4 = &$value1;
+
+// array_args an array containing elements with reference variables
+$array_arg = array(
+ 0 => 10,
+ 1 => &$value4,
+ 2 => &$value2,
+ 3 => 200,
+ 4 => &$value3,
+);
+
+echo "-- Sorting 'array_arg' containing different references --\n";
+var_dump( uasort($array_arg, 'cmp_function') ); // expecting: bool(true)
+var_dump($array_arg);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : 'array_arg' with elements as reference ***
+-- Sorting 'array_arg' containing different references --
+bool(true)
+array(5) {
+ [1]=>
+ &int(-5)
+ [4]=>
+ &int(0)
+ [0]=>
+ int(10)
+ [2]=>
+ &int(100)
+ [3]=>
+ int(200)
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - different associative arrays
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/* Testing uasort() with different associative arrays having keys as
+ * string, integer, default & duplicate keys
+ */
+
+echo "*** Testing uasort() : sorting different associative arrays ***\n";
+
+// comparison function
+/* Prototype : int cmp(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+
+// Array with duplicate string and integer keys
+$array_arg = array(0 => 2, "a" => 8, "d" => 9, 3 => 3, 5 => 2, "o" => 6, "z" => -99, 0 => 1, "z" => 3);
+echo "-- Array with duplicate keys --\n";
+var_dump( uasort($array_arg, 'cmp') );
+var_dump($array_arg);
+
+// Array with default and assigned keys
+$array_arg = array(0 => "Banana", 1 => "Mango", "Orange", 2 => "Apple", "Pineapple");
+echo "-- Array with default/assigned keys --\n";
+var_dump( uasort($array_arg, 'cmp') );
+var_dump($array_arg);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : sorting different associative arrays ***
+-- Array with duplicate keys --
+bool(true)
+array(7) {
+ [0]=>
+ int(1)
+ [5]=>
+ int(2)
+ ["z"]=>
+ int(3)
+ [3]=>
+ int(3)
+ ["o"]=>
+ int(6)
+ ["a"]=>
+ int(8)
+ ["d"]=>
+ int(9)
+}
+-- Array with default/assigned keys --
+bool(true)
+array(4) {
+ [2]=>
+ string(5) "Apple"
+ [0]=>
+ string(6) "Banana"
+ [1]=>
+ string(5) "Mango"
+ [3]=>
+ string(9) "Pineapple"
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - unexpected values for 'cmp_function' argument
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing uasort() function with different scalar and nonscalar values in place of 'cmp_function'
+*/
+
+echo "*** Testing uasort() : Unexpected values in place of comparison function ***\n";
+
+// Class definition for object variable
+class MyClass
+{
+ public function __toString()
+ {
+ return 'object';
+ }
+}
+
+$array_arg = array(0 => 1, 1 => -1, 2 => 3, 3 => 10, 4 => 4, 5 => 2, 6 => 8, 7 => 5);
+
+// Get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// Get resource variable
+$fp = fopen(__FILE__,'r');
+
+// different values for 'cmp_function'
+$cmp_values = array(
+
+ // int data
+/*1*/ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+/*5*/ 10.5,
+ -10.5,
+ 10.1234567e8,
+ 10.7654321E-8,
+ .5,
+
+ // array data
+/*10*/ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+/*15*/ NULL,
+ null,
+
+ // boolean data
+/*17*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*21*/ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+/*25*/ new MyClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ @$undefined_var,
+
+ // unset data
+/*28*/ @$unset_var,
+);
+
+// loop through each element of the cmp_values for 'cmp_function'
+for($count = 0; $count < count($cmp_values); $count++) {
+ echo "-- Iteration ".($count + 1)." --\n";
+ var_dump( uasort($array_arg, $cmp_values[$count]) );
+};
+
+//closing resource
+fclose($fp);
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : Unexpected values in place of comparison function ***
+-- Iteration 1 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 7 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 8 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 9 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 10 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 11 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 12 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 13 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 14 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 15 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 16 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 17 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 18 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 19 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 20 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 21 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 22 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 23 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 24 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 25 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 26 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 27 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Iteration 28 --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - sort different numeric values
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* sorting different types of numeric arrays containing data of following type:
+* integer, octal, hexadecimal & float
+*/
+
+// comparision function
+/* Prototype : int cmp_function(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp_function($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else {
+ return -1;
+ }
+}
+
+echo "*** Testing uasort() : different numeric arrays as 'array_arg' ***\n";
+
+// Int array
+$int_values = array(0 => 3, 1 => 2, 3 => 100, 4 => 150, 5 => 25, 6 => 350, 7 => 0, 8 => -3, 9 => -1200);
+echo "-- Sorting Integer array --\n";
+var_dump( uasort($int_values, 'cmp_function') ); // expecting: bool(true)
+var_dump($int_values);
+
+// Octal array
+$octal_values = array(0 => 056, 1 => 023, 2 => 090, 3 => 015, 4 => -045, 5 => 01, 6 => -078);
+echo "-- Sorting Octal array --\n";
+var_dump( uasort($octal_values, 'cmp_function') ); // expecting: bool(true)
+var_dump($octal_values);
+
+// Hexadecimal array
+$hex_values = array(0 => 0xAE, 1 => 0x2B, 2 => 0X10, 3 => -0xCF, 4 => 0X12, 5 => -0XF2);
+echo "-- Sorting Hex array --\n";
+var_dump( uasort($hex_values, 'cmp_function') ); // expecting: bool(true)
+var_dump($hex_values);
+
+// Float array
+$float_values = array( 0 => 10.2, 1 => 2.4, 2 => -3.4, 3 => 0, 4 => 0.5, 5 => 7.3e3, 6 => -9.34E-2);
+echo "-- Sorting Float array --\n";
+var_dump( uasort($float_values, 'cmp_function') ); // expecting: bool(true)
+var_dump($float_values);
+
+// empty array
+$empty_array = array();
+echo "-- Sorting empty array --\n";
+var_dump( uasort($empty_array, 'cmp_function') ); // expecting: bool(true)
+var_dump($empty_array);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : different numeric arrays as 'array_arg' ***
+-- Sorting Integer array --
+bool(true)
+array(9) {
+ [9]=>
+ int(-1200)
+ [8]=>
+ int(-3)
+ [7]=>
+ int(0)
+ [1]=>
+ int(2)
+ [0]=>
+ int(3)
+ [5]=>
+ int(25)
+ [3]=>
+ int(100)
+ [4]=>
+ int(150)
+ [6]=>
+ int(350)
+}
+-- Sorting Octal array --
+bool(true)
+array(7) {
+ [4]=>
+ int(-37)
+ [6]=>
+ int(-7)
+ [2]=>
+ int(0)
+ [5]=>
+ int(1)
+ [3]=>
+ int(13)
+ [1]=>
+ int(19)
+ [0]=>
+ int(46)
+}
+-- Sorting Hex array --
+bool(true)
+array(6) {
+ [5]=>
+ int(-242)
+ [3]=>
+ int(-207)
+ [2]=>
+ int(16)
+ [4]=>
+ int(18)
+ [1]=>
+ int(43)
+ [0]=>
+ int(174)
+}
+-- Sorting Float array --
+bool(true)
+array(7) {
+ [2]=>
+ float(-3.4)
+ [6]=>
+ float(-0.0934)
+ [3]=>
+ int(0)
+ [4]=>
+ float(0.5)
+ [1]=>
+ float(2.4)
+ [0]=>
+ float(10.2)
+ [5]=>
+ float(7300)
+}
+-- Sorting empty array --
+bool(true)
+array(0) {
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - sort diff. strings
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* sorting different strings:
+* single quoted, double quoted and heredoc strings
+*/
+
+// comparison function
+/* Prototype : int cmp_function(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp_function($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else {
+ return -1;
+ }
+}
+
+// Different heredoc strings to be sorted
+$empty_heredoc =<<<EOT
+EOT;
+
+$simple_heredoc1 =<<<EOT
+Heredoc
+EOT;
+
+$simple_heredoc2 =<<<EOT
+HEREDOC
+EOT;
+
+$multiline_heredoc =<<<EOT
+heredoc string\twith!@# and 123
+Test this!!!
+EOT;
+
+
+echo "*** Testing uasort() : different string arrays as 'array_arg' ***\n";
+
+// Single quoted strings
+$single_quoted_values = array(
+ 0 => ' ', 1 => 'test', 3 => 'Hello', 4 => 'HELLO',
+ 5 => '', 6 => '\t', 7 => '0', 8 => '123Hello', 9 => '\'', 10 => '@#$%'
+);
+echo "-- Sorting Single Quoted String values --\n";
+var_dump( uasort($single_quoted_values, 'cmp_function') ); // expecting: bool(true)
+var_dump($single_quoted_values);
+
+// Double quoted strings
+$double_quoted_values = array(
+ 0 => " ", 1 => "test", 3 => "Hello", 4 => "HELLO",
+ 5 => "", 6 => "\t", 7 => "0", 8 => "123Hello", 9 => "\"", 10 => "@#$%"
+);
+echo "-- Sorting Double Quoted String values --\n";
+var_dump( uasort($double_quoted_values, 'cmp_function') ); // expecting: bool(true)
+var_dump($double_quoted_values);
+
+// Heredoc strings
+$heredoc_values = array(0 => $empty_heredoc, 1 => $simple_heredoc1, 2 => $simple_heredoc2, 3 => $multiline_heredoc);
+echo "-- Sorting Heredoc String values --\n";
+var_dump( uasort($heredoc_values, 'cmp_function') ); // expecting: bool(true)
+var_dump($heredoc_values);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : different string arrays as 'array_arg' ***
+-- Sorting Single Quoted String values --
+bool(true)
+array(10) {
+ [5]=>
+ string(0) ""
+ [0]=>
+ string(1) " "
+ [9]=>
+ string(1) "'"
+ [7]=>
+ string(1) "0"
+ [8]=>
+ string(8) "123Hello"
+ [10]=>
+ string(4) "@#$%"
+ [4]=>
+ string(5) "HELLO"
+ [3]=>
+ string(5) "Hello"
+ [6]=>
+ string(2) "\t"
+ [1]=>
+ string(4) "test"
+}
+-- Sorting Double Quoted String values --
+bool(true)
+array(10) {
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(1) " "
+ [0]=>
+ string(1) " "
+ [9]=>
+ string(1) """
+ [7]=>
+ string(1) "0"
+ [8]=>
+ string(8) "123Hello"
+ [10]=>
+ string(4) "@#$%"
+ [4]=>
+ string(5) "HELLO"
+ [3]=>
+ string(5) "Hello"
+ [1]=>
+ string(4) "test"
+}
+-- Sorting Heredoc String values --
+bool(true)
+array(4) {
+ [0]=>
+ string(0) ""
+ [2]=>
+ string(7) "HEREDOC"
+ [1]=>
+ string(7) "Heredoc"
+ [3]=>
+ string(43) "heredoc string with!@# and 123
+Test this!!!"
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - sort array having subarrays
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Testing uasort() with 'array_arg' having different subarrays as array elements
+*/
+
+// comparison function
+/* Prototype : int cmp_function(mixed $value1, mixed $value2)
+ * Parameters : $value1 and $value2 - values to be compared
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp_function($value1, $value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else {
+ return -1;
+ }
+}
+
+echo "*** Testing uasort() : sorting array having different subarrays ***\n";
+
+$array_args = array(
+ 0 => array(2, 10, -1),
+ 1 => array(100),
+ 2 => array(),
+ 3 => array(0),
+ 4 => array(-1),
+ 5 => array(-9, 34, 54, 0, 20),
+ 6 => array(''),
+ 7 => array("apple", "Apple", "APPLE", "aPPle", "aPpLe")
+);
+$temp_array = $array_args;
+// sorting array_arg as whole array
+var_dump( uasort($temp_array, 'cmp_function') ); // expecting: bool(true)
+var_dump($temp_array);
+
+?>
+--EXPECTF--
+*** Testing uasort() : sorting array having different subarrays ***
+bool(true)
+array(8) {
+ [2]=>
+ array(0) {
+ }
+ [4]=>
+ array(1) {
+ [0]=>
+ int(-1)
+ }
+ [6]=>
+ array(1) {
+ [0]=>
+ string(0) ""
+ }
+ [3]=>
+ array(1) {
+ [0]=>
+ int(0)
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ int(100)
+ }
+ [0]=>
+ array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(10)
+ [2]=>
+ int(-1)
+ }
+ [5]=>
+ array(5) {
+ [0]=>
+ int(-9)
+ [1]=>
+ int(34)
+ [2]=>
+ int(54)
+ [3]=>
+ int(0)
+ [4]=>
+ int(20)
+ }
+ [7]=>
+ array(5) {
+ [0]=>
+ string(5) "apple"
+ [1]=>
+ string(5) "Apple"
+ [2]=>
+ string(5) "APPLE"
+ [3]=>
+ string(5) "aPPle"
+ [4]=>
+ string(5) "aPpLe"
+ }
+}
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - anonymous function as 'cmp_function'
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing different anonymous functions as 'cmp_function'
+* arguments passed by value
+* arguments passed by reference
+*/
+
+echo "*** Testing uasort() : anonymous function as 'cmp_function' ***\n";
+
+$cmp_function = 'if($value1 == $value2) {return 0;} else if($value1 > $value2) {return 1;} else{return -1;}';
+
+$array_arg = array(0 => 100, 1 => 3, 2 => -70, 3 => 24, 4 => 90);
+echo "-- Anonymous 'cmp_function' with parameters passed by value --\n";
+var_dump( uasort($array_arg, create_function('$value1, $value2',$cmp_function) ) );
+var_dump($array_arg);
+
+$array_arg = array("b" => "Banana", "m" => "Mango", "a" => "Apple", "p" => "Pineapple");
+echo "-- Anonymous 'cmp_function' with parameters passed by reference --\n";
+var_dump( uasort($array_arg, create_function('&$value1, &$value2', $cmp_function) ) );
+var_dump($array_arg);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : anonymous function as 'cmp_function' ***
+-- Anonymous 'cmp_function' with parameters passed by value --
+bool(true)
+array(5) {
+ [2]=>
+ int(-70)
+ [1]=>
+ int(3)
+ [3]=>
+ int(24)
+ [4]=>
+ int(90)
+ [0]=>
+ int(100)
+}
+-- Anonymous 'cmp_function' with parameters passed by reference --
+bool(true)
+array(4) {
+ ["a"]=>
+ string(5) "Apple"
+ ["b"]=>
+ string(6) "Banana"
+ ["m"]=>
+ string(5) "Mango"
+ ["p"]=>
+ string(9) "Pineapple"
+}
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - built-in function as 'cmp_function'
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/*
+* Passing different built-in library functions in place of 'cmp_function'
+* valid comparison functions: strcmp() & strcasecmp()
+* language constructs: echo & exit
+*/
+
+echo "*** Testing uasort() : built in function as 'cmp_function' ***\n";
+// Initializing variables
+$array_arg = array("b" => "Banana", "m" => "Mango", "a" => "apple", "p" => "Pineapple", "o" => "orange");
+$builtin_fun_arg = $array_arg;
+$languageConstruct_fun_arg = $array_arg;
+
+// Testing library functions as comparison function
+echo "-- Testing uasort() with built-in 'cmp_function': strcasecmp() --\n";
+var_dump( uasort($builtin_fun_arg, 'strcasecmp') ); // expecting: bool(true)
+var_dump($builtin_fun_arg);
+
+echo "-- Testing uasort() with built-in 'cmp_function': strcmp() --\n";
+var_dump( uasort($array_arg, 'strcmp') ); // expecting: bool(true)
+var_dump($array_arg);
+
+// Testing with language construct as comparison function
+echo "-- Testing uasort() with language construct as 'cmp_function' --\n";
+var_dump( uasort($languageConstruct_fun_arg, 'echo') ); // expecting: bool(false)
+
+echo "-- Testing uasort() with language construct as 'cmp_function' --\n";
+var_dump( uasort($languageConstruct_fun_arg, 'exit') ); // expecting: bool(false)
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : built in function as 'cmp_function' ***
+-- Testing uasort() with built-in 'cmp_function': strcasecmp() --
+bool(true)
+array(5) {
+ ["a"]=>
+ string(5) "apple"
+ ["b"]=>
+ string(6) "Banana"
+ ["m"]=>
+ string(5) "Mango"
+ ["o"]=>
+ string(6) "orange"
+ ["p"]=>
+ string(9) "Pineapple"
+}
+-- Testing uasort() with built-in 'cmp_function': strcmp() --
+bool(true)
+array(5) {
+ ["b"]=>
+ string(6) "Banana"
+ ["m"]=>
+ string(5) "Mango"
+ ["p"]=>
+ string(9) "Pineapple"
+ ["a"]=>
+ string(5) "apple"
+ ["o"]=>
+ string(6) "orange"
+}
+-- Testing uasort() with language construct as 'cmp_function' --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+-- Testing uasort() with language construct as 'cmp_function' --
+
+Warning: uasort(): Invalid comparison function in %s on line %d
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test uasort() function : usage variations - 'cmp_function' with reference argument
+--FILE--
+<?php
+/* Prototype : bool uasort(array $array_arg, string $cmp_function)
+ * Description: Sort an array with a user-defined comparison function and maintain index association
+ * Source code: ext/standard/array.c
+*/
+
+/* Testing uasort() functionality with comparison function having arguments as reference
+ */
+
+echo "*** Testing uasort() : 'cmp_function' with reference arguments ***\n";
+
+// comparison function
+/* Prototype : int cmp(mixed &$value1, mixed &$value2)
+ * Parameters : $value1 and $value2 - values recieved by reference
+ * Return value : 0 - if both values are same
+ * 1 - if value1 is greater than value2
+ * -1 - if value1 is less than value2
+ * Description : compares value1 and value2
+ */
+function cmp(&$value1, &$value2)
+{
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 > $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+
+// Int array with default keys
+$int_values = array(1, 8, 9, 3, 2, 6, 7);
+echo "-- Passing integer values to 'cmp_function' --\n";
+var_dump( uasort($int_values, 'cmp') );
+var_dump($int_values);
+
+// String array with default keys
+$string_values = array("Mango", "Apple", "Orange", "Banana");
+echo "-- Passing string values to 'cmp_function' --\n";
+var_dump( uasort($string_values, 'cmp') );
+var_dump($string_values);
+
+echo "Done"
+?>
+--EXPECTF--
+*** Testing uasort() : 'cmp_function' with reference arguments ***
+-- Passing integer values to 'cmp_function' --
+bool(true)
+array(7) {
+ [0]=>
+ int(1)
+ [4]=>
+ int(2)
+ [3]=>
+ int(3)
+ [5]=>
+ int(6)
+ [6]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+}
+-- Passing string values to 'cmp_function' --
+bool(true)
+array(4) {
+ [1]=>
+ string(5) "Apple"
+ [3]=>
+ string(6) "Banana"
+ [0]=>
+ string(5) "Mango"
+ [2]=>
+ string(6) "Orange"
+}
+Done