Sorts the array (ascendant by default).
public sort ( string $key = null, callable $callback = null ) : array | ||
$key | string | Element to sort using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]" |
$callback | callable | Callback should be a function with the following signature: ```php function($element1, $element2) { // returns -1, 0 or 1 } ``` |
return | array |
public function testSortKey() { $a = new ArrayWrapper(['level1' => ['a' => '2015-11-01', 'b' => '2015-11-03', 'c' => '2015-11-02']]); $b = $a->sort('level1'); $this->assertCount(3, $b); $this->assertEquals('2015-11-01', array_values($b)[0]); $this->assertEquals('2015-11-02', array_values($b)[1]); $this->assertEquals('2015-11-03', array_values($b)[2]); }