1--TEST--
2Test sort() function : usage variations - sort mixed values, 'sort_flag' as defualt/SORT_REGULAR (OK to fail as result is unpredectable)
3--FILE--
4<?php
5/* Prototype  : bool sort ( array &$array [, int $sort_flags] )
6 * Description: This function sorts an array.
7                Elements will be arranged from lowest to highest when this function has completed.
8 * Source code: ext/standard/array.c
9*/
10
11/*
12 * testing sort() by providing mixed value array for $array argument with following flag values.
13 * flag value as defualt
14 * SORT_REGULAR - compare items normally
15*/
16
17echo "*** Testing sort() : usage variations ***\n";
18
19// mixed value array
20$mixed_values = array (
21  array(),
22  array(array(33, -5, 6), array(11), array(22, -55), array() ),
23  -4, "4", 4.00, "b", "5", -2, -2.0, -2.98989, "-.9", "True", "",
24  NULL, "ab", "abcd", 0.0, -0, "abcd\x00abcd\x00abcd", '', true, false
25);
26
27echo "\n-- Testing sort() by supplying mixed value array, 'flag' value is defualt --\n";
28$temp_array = $mixed_values;
29var_dump(sort($temp_array) );
30var_dump($temp_array);
31
32echo "\n-- Testing sort() by supplying mixed value array, 'flag' value is SORT_REGULAR --\n";
33$temp_array = $mixed_values;
34var_dump(sort($temp_array, SORT_REGULAR) );
35var_dump($temp_array);
36
37echo "Done\n";
38?>
39--EXPECTF--
40*** Testing sort() : usage variations ***
41
42-- Testing sort() by supplying mixed value array, 'flag' value is defualt --
43bool(true)
44array(22) {
45  [0]=>
46  bool(false)
47  [1]=>
48  int(-4)
49  [2]=>
50  float(-2.98989)
51  [3]=>
52  int(-2)
53  [4]=>
54  float(-2)
55  [5]=>
56  string(3) "-.9"
57  [6]=>
58  float(0)
59  [7]=>
60  string(0) ""
61  [8]=>
62  int(0)
63  [9]=>
64  string(0) ""
65  [10]=>
66  NULL
67  [11]=>
68  string(1) "4"
69  [12]=>
70  bool(true)
71  [13]=>
72  string(1) "5"
73  [14]=>
74  string(4) "True"
75  [15]=>
76  string(2) "ab"
77  [16]=>
78  string(4) "abcd"
79  [17]=>
80  string(14) "abcd�abcd�abcd"
81  [18]=>
82  string(1) "b"
83  [19]=>
84  float(4)
85  [20]=>
86  array(0) {
87  }
88  [21]=>
89  array(4) {
90    [0]=>
91    array(3) {
92      [0]=>
93      int(33)
94      [1]=>
95      int(-5)
96      [2]=>
97      int(6)
98    }
99    [1]=>
100    array(1) {
101      [0]=>
102      int(11)
103    }
104    [2]=>
105    array(2) {
106      [0]=>
107      int(22)
108      [1]=>
109      int(-55)
110    }
111    [3]=>
112    array(0) {
113    }
114  }
115}
116
117-- Testing sort() by supplying mixed value array, 'flag' value is SORT_REGULAR --
118bool(true)
119array(22) {
120  [0]=>
121  bool(false)
122  [1]=>
123  int(-4)
124  [2]=>
125  float(-2.98989)
126  [3]=>
127  int(-2)
128  [4]=>
129  float(-2)
130  [5]=>
131  string(3) "-.9"
132  [6]=>
133  float(0)
134  [7]=>
135  string(0) ""
136  [8]=>
137  int(0)
138  [9]=>
139  string(0) ""
140  [10]=>
141  NULL
142  [11]=>
143  string(1) "4"
144  [12]=>
145  bool(true)
146  [13]=>
147  string(1) "5"
148  [14]=>
149  string(4) "True"
150  [15]=>
151  string(2) "ab"
152  [16]=>
153  string(4) "abcd"
154  [17]=>
155  string(14) "abcd�abcd�abcd"
156  [18]=>
157  string(1) "b"
158  [19]=>
159  float(4)
160  [20]=>
161  array(0) {
162  }
163  [21]=>
164  array(4) {
165    [0]=>
166    array(3) {
167      [0]=>
168      int(33)
169      [1]=>
170      int(-5)
171      [2]=>
172      int(6)
173    }
174    [1]=>
175    array(1) {
176      [0]=>
177      int(11)
178    }
179    [2]=>
180    array(2) {
181      [0]=>
182      int(22)
183      [1]=>
184      int(-55)
185    }
186    [3]=>
187    array(0) {
188    }
189  }
190}
191Done
192