Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Optional callback for Arr::sort() #21337

Merged
merged 1 commit into from
Sep 22, 2017
Merged

[5.5] Optional callback for Arr::sort() #21337

merged 1 commit into from
Sep 22, 2017

Conversation

fitztrev
Copy link
Contributor

Arr::sort() creates a Collection and uses Collection sorting methods where a $callback value is not required.

This PR makes Arr::sort() work like Collection::sort() in that $callback is optional.

Example

$fruits = [
    'banana',
    'pear',
    'apple'
];

// Before
$sorted = Arr::sort($fruits, function($fruit) {
    return $fruit;
});

// After
$sorted = Arr::sort($fruits);

// Result
$sorted == [
    'apple',
    'banana',
    'pear'
];

@fitztrev fitztrev changed the title Optional callback for Arr::sort() [5.5] Optional callback for Arr::sort() Sep 22, 2017
@taylorotwell taylorotwell merged commit 9754d89 into laravel:5.5 Sep 22, 2017
@fitztrev fitztrev deleted the array-sort-without-callback branch September 22, 2017 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants