public function sortBy(callable $callback, $key = null, $options = SORT_REGULAR, $isDescending = false)
    {
        $elements = [];
        $sourceElements = is_null($key) === true ? $this->array : $this->get($key);

        foreach ($sourceElements as $key => $value) {
            $elements[$key] = $callback($key, $value);
        }

        $isDescending ? arsort($elements, $options)
                    : asort($elements, $options);

        foreach (array_keys($elements) as $key) {
            $elements[$key] = $sourceElements[$key];
        }

        return $elements;
    }
public function sortBy(callable $callback, $key = null, $options = SORT_REGULAR, $isDescending = false)
    {
        $elements = [];
        $sourceElements = is_null($key) === true ? $this->array : $this->get($key);

        foreach ($sourceElements as $key => $value) {
            $elements[$key] = $callback($key, $value);
        }

        $isDescending ? arsort($elements, $options)
                    : asort($elements, $options);

        foreach (array_keys($elements) as $key) {
            $elements[$key] = $sourceElements[$key];
        }

        return $elements;
    }
public function sortBy ( callable $ callback , $ key = null , $ options = SORT_REGULAR , $ isDescending = false ) { $ elements = [ ] ; $ sourceElements = is_null ( $ key ) === true ? $ this -> array : $ this -> get ( $ key ) ; foreach ( $ sourceElements as $ key => $ value ) { $ elements [ $ key ] = $ callback ( $ key , $ value ) ; } $ isDescending ? arsort ( $ elements , $ options ) : asort ( $ elements , $ options ) ; foreach ( array_keys ( $ elements ) as $ key ) { $ elements [ $ key ] = $ sourceElements [ $ key ] ; } return $ elements ; }
Sort the array sing the given callback.

@param callable $callback Callback should be a function with
the following signature:

```php
function($key, $value)
{
// return $processedValue;
}
```
@param string $key          Element to sort using "dot" notation.
You can to escape a dot in a key surrendering with brackets: "[.]"
@param int    $options      See sort_flags at http://php.net/manual/es/function.sort.php
@param bool   $isDescending

@return array
Sort the array sing the given callback .