import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / sort_object1.php
blob99a56a3158975c17bc382d5710b31702551702f2
1 <?php
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 */
7 /*
8 * testing sort() by providing integer/string object arrays with flag values are defualt, SORT_REGULAR
9 */
11 echo "*** Testing sort() : object functionality ***\n";
13 // class declaration for integer objects
14 class for_integer_sort
16 public $class_value;
17 // initializing object member value
18 function __construct($value){
19 $this->class_value = $value;
24 // class declaration for string objects
25 class for_string_sort
27 public $class_value;
28 // initializing object member value
29 function __construct($value){
30 $this->class_value = $value;
33 // return string value
34 function __tostring() {
35 return (string)$this->value;
40 // array of integer objects
41 $unsorted_int_obj = array(
42 new for_integer_sort(11), new for_integer_sort(66),
43 new for_integer_sort(23), new for_integer_sort(-5),
44 new for_integer_sort(0.001), new for_integer_sort(0)
47 // array of string objects
48 $unsorted_str_obj = array (
49 new for_string_sort("axx"), new for_string_sort("t"),
50 new for_string_sort("w"), new for_string_sort("py"),
51 new for_string_sort("apple"), new for_string_sort("Orange"),
52 new for_string_sort("Lemon"), new for_string_sort("aPPle")
56 echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is defualt --\n";
58 // testing sort() function by supplying integer object array, flag value is defualt
59 $temp_array = $unsorted_int_obj;
60 var_dump(sort($temp_array) );
61 var_dump($temp_array);
63 // testing sort() function by supplying string object array, flag value is defualt
64 $temp_array = $unsorted_str_obj;
65 var_dump(sort($temp_array) );
66 var_dump($temp_array);
68 echo "\n-- Testing sort() by supplying various object arrays, 'flag' value is SORT_REGULAR --\n";
69 // testing sort() function by supplying integer object array, flag value = SORT_REGULAR
70 $temp_array = $unsorted_int_obj;
71 var_dump(sort($temp_array, SORT_REGULAR) );
72 var_dump($temp_array);
74 // testing sort() function by supplying string object array, flag value = SORT_REGULAR
75 $temp_array = $unsorted_str_obj;
76 var_dump(sort($temp_array, SORT_REGULAR) );
77 var_dump($temp_array);
79 echo "Done\n";