/hphp/test/slow/array_object/uasort.php
http://github.com/facebook/hiphop-php · PHP · 27 lines · 21 code · 3 blank · 3 comment · 2 complexity · 9b579fb73bf5e30dd25b79abf73f4962 MD5 · raw file
- <?php
- // Comparison function
- function cmp($a, $b) {
- if ($a == $b) {
- return 0;
- }
- return ($a < $b) ? -1 : 1;
- }
- // Array to be sorted
- $array = array(
- 'a' => 4,
- 'b' => 8,
- 'c' => -1,
- 'd' => -9,
- 'e' => 2,
- 'f' => 5,
- 'g' => 3,
- 'h' => -4,
- );
- $arrayObject = new ArrayObject($array);
- print_r($arrayObject);
- // Sort and print the resulting array
- $arrayObject->uasort('cmp');
- print_r($arrayObject);