nahid / jsonq

A PHP query builder for JSON
Creative Commons Zero v1.0 Universal
872 stars 105 forks source link

Added sortByCallable method #36

Closed tobias-kuendig closed 5 years ago

tobias-kuendig commented 6 years ago

Sometimes more control over sorting is needed than the two column and direction parameters.

This PR adds a sortByCallable method that allows a user to specify a custom sort function.

I need this specific case to implement a sort by random functionality.

$sortRandom = function($a, $b) {
   return random_int(-1, 1);
}
$jsonq->sortByCallable($sortRandom);