/** * @covers StableSort::uksort * @group stablesort */ public function testFloat() { $source = array('a3' => 0.1, 'b2' => 0.2, 'c2' => 0.3, 'd1' => 0.4); $expected = array('d1' => 0.4, 'b2' => 0.2, 'c2' => 0.3, 'a3' => 0.1); $array = $source; StableSort::uksort($array, array(__CLASS__, 'compare_string_skip')); $this->assertSame($expected, $array); }
/** * @covers StableSort::uasort * @group stablesort */ public function testFloat() { $source = array('a' => array('red', 0.3), 'b' => array('green', 0.2), 'c' => array('blue', 0.2), 'd' => array('yellow', 0.1)); $expected = array('d' => array('yellow', 0.1), 'b' => array('green', 0.2), 'c' => array('blue', 0.2), 'a' => array('red', 0.3)); $array = $source; StableSort::uasort($array, array(__CLASS__, 'compare_float')); $this->assertSame($expected, $array); }
/** * @covers StableSort::natcasesort * @group stablesort */ public function testAssociation() { $array = array('a9', 'a1', 'a10', 'A2'); StableSort::natcasesort($array); $this->assertSame(array(1 => 'a1', 3 => 'A2', 0 => 'a9', 2 => 'a10'), $array); }
function sasort(array &$array, $sort_flags = SORT_REGULAR) { require_once dirname(__DIR__) . '/classes/StableSort.php'; return StableSort::asort($array, $sort_flags); }
function susort(array &$array, $value_compare_func) { require_once dirname(__DIR__) . '/classes/StableSort.php'; return StableSort::usort($array, $value_compare_func); }
function snatcasesort(array &$array) { require_once dirname(__DIR__) . '/classes/StableSort.php'; return StableSort::natcasesort($array); }
/** * @covers StableSort::asort * @group stablesort */ public function testRegular() { $array = array('a9', 'a1', 'a10'); StableSort::asort($array, SORT_REGULAR); $this->assertNotSame(array(1 => 'a1', 0 => 'a9', 2 => 'a10'), $array); }