1--TEST--
2Test rsort() function : usage variations - Hexadecimal vales
3--FILE--
4<?php
5/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
6 * Description: Sort an array in reverse order
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Pass rsort() an array of hexadecimal values to test behaviour
12 */
13
14echo "*** Testing rsort() : variation ***\n";
15
16// an array contains unsorted hexadecimal values
17$unsorted_hex_array = array(0x1AB, 0xFFF, 0xF, 0xFF, 0x2AA, 0xBB, 0x1ab, 0xff, -0xFF, 0, -0x2aa);
18
19echo "\n-- 'flag' value is defualt  --\n";
20$temp_array = $unsorted_hex_array;
21var_dump(rsort($temp_array) );
22var_dump($temp_array);
23
24echo "\n-- 'flag' value is SORT_REGULAR  --\n";
25$temp_array = $unsorted_hex_array;
26var_dump(rsort($temp_array, SORT_REGULAR) );
27var_dump($temp_array);
28
29echo "\n-- 'flag' value is SORT_NUMERIC  --\n";
30$temp_array = $unsorted_hex_array;
31var_dump(rsort($temp_array, SORT_NUMERIC) );
32var_dump($temp_array);
33
34echo "Done";
35?>
36--EXPECT--
37*** Testing rsort() : variation ***
38
39-- 'flag' value is defualt  --
40bool(true)
41array(11) {
42  [0]=>
43  int(4095)
44  [1]=>
45  int(682)
46  [2]=>
47  int(427)
48  [3]=>
49  int(427)
50  [4]=>
51  int(255)
52  [5]=>
53  int(255)
54  [6]=>
55  int(187)
56  [7]=>
57  int(15)
58  [8]=>
59  int(0)
60  [9]=>
61  int(-255)
62  [10]=>
63  int(-682)
64}
65
66-- 'flag' value is SORT_REGULAR  --
67bool(true)
68array(11) {
69  [0]=>
70  int(4095)
71  [1]=>
72  int(682)
73  [2]=>
74  int(427)
75  [3]=>
76  int(427)
77  [4]=>
78  int(255)
79  [5]=>
80  int(255)
81  [6]=>
82  int(187)
83  [7]=>
84  int(15)
85  [8]=>
86  int(0)
87  [9]=>
88  int(-255)
89  [10]=>
90  int(-682)
91}
92
93-- 'flag' value is SORT_NUMERIC  --
94bool(true)
95array(11) {
96  [0]=>
97  int(4095)
98  [1]=>
99  int(682)
100  [2]=>
101  int(427)
102  [3]=>
103  int(427)
104  [4]=>
105  int(255)
106  [5]=>
107  int(255)
108  [6]=>
109  int(187)
110  [7]=>
111  int(15)
112  [8]=>
113  int(0)
114  [9]=>
115  int(-255)
116  [10]=>
117  int(-682)
118}
119Done
120