1--TEST-- 2Test sort() function : usage variations - sort hexadecimal values 3--FILE-- 4<?php 5/* 6 * testing sort() by providing different hexa-decimal array for $array argument with following flag values 7 * flag value as default 8 * SORT_REGULAR - compare items normally 9 * SORT_NUMERIC - compare items numerically 10*/ 11 12echo "*** Testing sort() : usage variations ***\n"; 13 14// an array contains unsorted hexadecimal values 15$unsorted_hex_array = array(0x1AB, 0xFFF, 0xF, 0xFF, 0x2AA, 0xBB, 0x1ab, 0xff, -0xFF, 0, -0x2aa); 16 17echo "\n-- Testing sort() by supplying hexadecimal value array, 'flag' value is default --\n"; 18$temp_array = $unsorted_hex_array; 19var_dump(sort($temp_array) ); // expecting : bool(true) 20var_dump($temp_array); 21 22echo "\n-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR --\n"; 23$temp_array = $unsorted_hex_array; 24var_dump(sort($temp_array, SORT_REGULAR) ); // expecting : bool(true) 25var_dump($temp_array); 26 27echo "\n-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC --\n"; 28$temp_array = $unsorted_hex_array; 29var_dump(sort($temp_array, SORT_NUMERIC) ); // expecting : bool(true) 30var_dump($temp_array); 31 32echo "Done\n"; 33?> 34--EXPECT-- 35*** Testing sort() : usage variations *** 36 37-- Testing sort() by supplying hexadecimal value array, 'flag' value is default -- 38bool(true) 39array(11) { 40 [0]=> 41 int(-682) 42 [1]=> 43 int(-255) 44 [2]=> 45 int(0) 46 [3]=> 47 int(15) 48 [4]=> 49 int(187) 50 [5]=> 51 int(255) 52 [6]=> 53 int(255) 54 [7]=> 55 int(427) 56 [8]=> 57 int(427) 58 [9]=> 59 int(682) 60 [10]=> 61 int(4095) 62} 63 64-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_REGULAR -- 65bool(true) 66array(11) { 67 [0]=> 68 int(-682) 69 [1]=> 70 int(-255) 71 [2]=> 72 int(0) 73 [3]=> 74 int(15) 75 [4]=> 76 int(187) 77 [5]=> 78 int(255) 79 [6]=> 80 int(255) 81 [7]=> 82 int(427) 83 [8]=> 84 int(427) 85 [9]=> 86 int(682) 87 [10]=> 88 int(4095) 89} 90 91-- Testing sort() by supplying hexadecimal value array, 'flag' value is SORT_NUMERIC -- 92bool(true) 93array(11) { 94 [0]=> 95 int(-682) 96 [1]=> 97 int(-255) 98 [2]=> 99 int(0) 100 [3]=> 101 int(15) 102 [4]=> 103 int(187) 104 [5]=> 105 int(255) 106 [6]=> 107 int(255) 108 [7]=> 109 int(427) 110 [8]=> 111 int(427) 112 [9]=> 113 int(682) 114 [10]=> 115 int(4095) 116} 117Done 118