Permalink
Browse files

Merge pull request #2867 from JamShady/pull-request/collection-sortBy…

…-flags

Added sort flag to Collection::sortBy()
  • Loading branch information...
taylorotwell committed Dec 6, 2013
2 parents 1973197 + 7898aa6 commit 426c9e0e39915eedd2861b147ba6701443136e3d
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Illuminate/Support/Collection.php
@@ -220,9 +220,10 @@ public function sort(Closure $callback)
* Sort the collection using the given Closure.
*
* @param \Closure $callback
* @param int $options
* @return \Illuminate\Support\Collection
*/
public function sortBy(Closure $callback)
public function sortBy(Closure $callback, $options = SORT_REGULAR)
{
$results = array();
@@ -234,7 +235,7 @@ public function sortBy(Closure $callback)
$results[$key] = $callback($value);
}
asort($results);
asort($results, $options);
// Once we have sorted all of the keys in the array, we will loop through them
// and grab the corresponding model so we can set the underlying items list

0 comments on commit 426c9e0

Please sign in to comment.