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  int(-4)
47  [1]=>
48  float(-2.98989)
49  [2]=>
50  int(-2)
51  [3]=>
52  float(-2)
53  [4]=>
54  string(0) ""
55  [5]=>
56  string(0) ""
57  [6]=>
58  NULL
59  [7]=>
60  bool(false)
61  [8]=>
62  bool(true)
63  [9]=>
64  string(3) "-.9"
65  [10]=>
66  float(0)
67  [11]=>
68  int(0)
69  [12]=>
70  string(1) "4"
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  int(-4)
122  [1]=>
123  float(-2.98989)
124  [2]=>
125  int(-2)
126  [3]=>
127  float(-2)
128  [4]=>
129  string(0) ""
130  [5]=>
131  string(0) ""
132  [6]=>
133  NULL
134  [7]=>
135  bool(false)
136  [8]=>
137  bool(true)
138  [9]=>
139  string(3) "-.9"
140  [10]=>
141  float(0)
142  [11]=>
143  int(0)
144  [12]=>
145  string(1) "4"
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