1--TEST--
2Test usort, uksort and uasort
3--INI--
4precision=14
5--FILE--
6<?php
7require(__DIR__ . '/data.inc');
8
9function cmp ($a, $b) {
10    is_array ($a)
11        and $a = count($a);
12    is_array ($b)
13        and $b = count($b);
14    return strcmp ($a, $b);
15}
16
17echo "-- Testing uasort() --\n";
18uasort ($data, 'cmp');
19var_dump ($data);
20
21
22echo "\n-- Testing uksort() --\n";
23uksort ($data, 'cmp');
24var_dump ($data);
25
26echo "\n-- Testing usort() --\n";
27usort ($data, 'cmp');
28var_dump ($data);
29?>
30--EXPECT--
31-- Testing uasort() --
32array(8) {
33  [16777216]=>
34  float(-0.3333333333333333)
35  [-1000]=>
36  array(2) {
37    [0]=>
38    string(6) "banana"
39    [1]=>
40    string(6) "orange"
41  }
42  ["test"]=>
43  int(27)
44  [0]=>
45  string(3) "PHP"
46  [17]=>
47  string(27) "PHP: Hypertext Preprocessor"
48  [5]=>
49  string(4) "Test"
50  [1001]=>
51  string(6) "monkey"
52  [1000]=>
53  string(4) "test"
54}
55
56-- Testing uksort() --
57array(8) {
58  [-1000]=>
59  array(2) {
60    [0]=>
61    string(6) "banana"
62    [1]=>
63    string(6) "orange"
64  }
65  [0]=>
66  string(3) "PHP"
67  [1000]=>
68  string(4) "test"
69  [1001]=>
70  string(6) "monkey"
71  [16777216]=>
72  float(-0.3333333333333333)
73  [17]=>
74  string(27) "PHP: Hypertext Preprocessor"
75  [5]=>
76  string(4) "Test"
77  ["test"]=>
78  int(27)
79}
80
81-- Testing usort() --
82array(8) {
83  [0]=>
84  float(-0.3333333333333333)
85  [1]=>
86  array(2) {
87    [0]=>
88    string(6) "banana"
89    [1]=>
90    string(6) "orange"
91  }
92  [2]=>
93  int(27)
94  [3]=>
95  string(3) "PHP"
96  [4]=>
97  string(27) "PHP: Hypertext Preprocessor"
98  [5]=>
99  string(4) "Test"
100  [6]=>
101  string(6) "monkey"
102  [7]=>
103  string(4) "test"
104}
105