/** * @covers sarsort * @group stablesort */ public function testSarsort() { $source = array('a' => 1, 'b' => 2, 'c' => 2, 'd' => 3); $expected = array('d' => 3, 'b' => 2, 'c' => 2, 'a' => 1); $array = $source; sarsort($array); $this->assertSame($expected, $array); }
/** * @covers sarsort * @group stablesort */ public function testRegular() { $array = array('a9', 'a1', 'a10'); sarsort($array, SORT_REGULAR); $this->assertNotSame(array(2 => 'a10', 0 => 'a9', 1 => 'a1'), $array); }
/** * * * @since 1.0.0 * @return array Sorted comments array */ public function get_comment_sort_replies($comments, $direction_bool) { // returns array[0]= reply count, array[1]=date stamps $walk = new Co_Mment_Walker_Sort(); $walkOutput = $walk->walk($comments, 0); $walkOutputReplies = $walkOutput[0]; if ($direction_bool == true) { sasort($walkOutputReplies); } else { sarsort($walkOutputReplies); } $comment_root_sorted = $walkOutputReplies; $comments_sorted = $this->merge_comment_array($comments, $comment_root_sorted); return $comments_sorted; }