Sort chart [skip ci]

This commit is contained in:
James Cole
2015-05-21 18:57:14 +02:00
parent e08a23948f
commit ff0379182e
2 changed files with 15 additions and 2 deletions

View File

@@ -79,6 +79,19 @@ class CategoryController extends Controller
$end = Session::get('end', Carbon::now()->endOfMonth());
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
// sort by callback:
uasort(
$set,
function ($left, $right) {
if ($left['sum'] == $right['sum']) {
return 0;
}
return ($left['sum'] < $right['sum']) ? 1 : -1;
}
);
foreach ($set as $entry) {
$sum = floatval($entry['sum']);
if ($sum != 0) {