public function testUksort() { $function = function ($a, $b) { $a = preg_replace('@^(a|an|the) @', '', $a); $b = preg_replace('@^(a|an|the) @', '', $b); return strcasecmp($a, $b); }; $ar = new ArrayObject(array('John' => 1, 'the Earth' => 2, 'an apple' => 3, 'a banana' => 4)); $sorted = $ar->getArrayCopy(); uksort($sorted, $function); $ar->uksort($function); $this->assertSame($sorted, $ar->getArrayCopy()); }