1--TEST-- 2SPL: SplHeap: comparison callback 3--FILE-- 4<?php 5class myHeap extends SplHeap { 6 public function compare($a, $b) { 7 if ($a > $b) { 8 $result = 1; 9 } else if ($a < $b) { 10 $result = -1; 11 } else { 12 $result = 0; 13 } 14 return $result; 15 } 16} 17 18$h = new myHeap; 19 20$in = range(0,10); 21shuffle($in); 22foreach ($in as $i) { 23 $h->insert($i); 24} 25 26foreach ($h as $out) { 27 echo $out."\n"; 28} 29?> 30===DONE=== 31<?php exit(0); ?> 32--EXPECT-- 3310 349 358 367 376 385 394 403 412 421 430 44===DONE=== 45