<NME> DashboardController.php
<BEF> <?php

namespace REBELinBLUE\Deployer\Http\Controllers;

use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Contracts\Translation\Translator;
use Illuminate\Contracts\View\Factory as ViewFactory;
use REBELinBLUE\Deployer\Repositories\Contracts\DeploymentRepositoryInterface;
use REBELinBLUE\Deployer\Repositories\Contracts\ProjectRepositoryInterface;

/**
 * The dashboard controller.
 */
class DashboardController extends Controller
{
    /**
     * @var ViewFactory
     */
    private $view;

    /**
     * @var DeploymentRepositoryInterface
     */
    private $deploymentRepository;

    /**
     * @var ProjectRepositoryInterface
     */
    private $projectRepository;

    /**
     * @var Translator
     */
    private $translator;

    /**
     * DashboardController constructor.
     *
     * @param DeploymentRepositoryInterface $deploymentRepository
     * @param ProjectRepositoryInterface    $projectRepository
     * @param ViewFactory                   $view
     * @param Translator                    $translator
            $projects_by_group[$project->group->name][] = $project;
        }

        return view('dashboard.index', [
            'title'    => Lang::get('dashboard.title'),
            'latest'   => $deploys_by_date,
        $this->deploymentRepository = $deploymentRepository;
        $this->projectRepository    = $projectRepository;
        $this->translator           = $translator;
    }

    /**
     * The main page of the dashboard.
     *
     * @return \Illuminate\View\View
     */
    public function index()
    {
        $projects = $this->projectRepository->getAll();

        $projects_by_group = [];
        foreach ($projects as $project) {
            if (!isset($projects_by_group[$project->group->name])) {
                $projects_by_group[$project->group->name] = [];
            }

            $projects_by_group[$project->group->name][] = $project;
        }

        ksort($projects_by_group);

        return $this->view->make('dashboard.index', [
            'title'     => $this->translator->trans('dashboard.title'),
            'latest'    => $this->buildTimelineData(),
            'projects'  => $projects_by_group,
        ]);
    }

    /**
     * Returns the timeline.
     *
     * @return \Illuminate\View\View
     */
    public function timeline()
    {
        return $this->view->make('dashboard.timeline', [
            'latest' => $this->buildTimelineData(),
        ]);
    }

    /**
     * Generates an XML file for CCTray.
     *
     * @param ResponseFactory $response
     *
     * @return \Illuminate\View\View
     */
    public function cctray(ResponseFactory $response)
    {
        $projects = $this->projectRepository->getAll();

        foreach ($projects as $project) {
            $project->latest_deployment = $project->deployments->first();
        }

        return $response->view('cctray', [
            'projects' => $projects,
        ])->header('Content-Type', 'application/xml');
    }

    /**
     * Builds the data for the timeline.
     *
     * @return array
     */
    private function buildTimelineData()
    {
        $deployments = $this->deploymentRepository->getTimeline();

        $deploys_by_date = [];
        foreach ($deployments as $deployment) {
            $date = $deployment->started_at->format('Y-m-d');

            if (!isset($deploys_by_date[$date])) {
                $deploys_by_date[$date] = [];
            }

            $deploys_by_date[$date][] = $deployment;
        }

        return $deploys_by_date;
    }
}

<MSG> Fixes #3 order of projects on dashboard not matching the navigation

<DFF> @@ -43,6 +43,8 @@ class DashboardController extends Controller
             $projects_by_group[$project->group->name][] = $project;
         }
 
+        ksort($projects_by_group);
+
         return view('dashboard.index', [
             'title'    => Lang::get('dashboard.title'),
             'latest'   => $deploys_by_date,

{'commit': "diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php\nindex f0964532..3e00847a 100644\n--- a/app/Http/Controllers/DashboardController.php\n+++ b/app/Http/Controllers/DashboardController.php\n@@ -43,6 +43,8 @@ class DashboardController extends Controller\n             $projects_by_group[$project->group->name][] = $project;\n         }\n \n+        ksort($projects_by_group);\n+\n         return view('dashboard.index', [\n             'title'    => Lang::get('dashboard.title'),\n             'latest'   => $deploys_by_date,\n", 'commit_subject': 'Fixes #3 order of projects on dashboard not matching the navigation', 'repo_name': 'REBELinBLUE/deployer', 'committer': {'name': 'Stephen Ball', 'email': '06fa905d7f2aaced6dc72e9511c71a2a51e8aead@rebelinblue.com', 'time_sec': '1429110753', 'tz_offset': '0', 'date': {'seconds': '1429110753'}}, 'commit_tree': 'ca1104f9c629a846e0e3702e559acf8bde08b8c7', 'commit_message': 'Fixes #3 order of projects on dashboard not matching the navigation\n', 'language_name': 'JavaScript', 'license': 'mit', 'hunks': "@@ -43,6 +43,8 @@ class DashboardController extends Controller\n             $projects_by_group[$project->group->name][] = $project;\n         }\n \n+        ksort($projects_by_group);\n+\n         return view('dashboard.index', [\n             'title'    => Lang::get('dashboard.title'),\n             'latest'   => $deploys_by_date,\n", 'addition_count': 2, 'deletion_count': 0, 'src_file': 'a/app/Http/Controllers/DashboardController.php', 'tgt_file': 'b/app/Http/Controllers/DashboardController.php', 'file_extension': '.php', 'before_file': "<?php\n\nnamespace REBELinBLUE\\Deployer\\Http\\Controllers;\n\nuse Illuminate\\Contracts\\Routing\\ResponseFactory;\nuse Illuminate\\Contracts\\Translation\\Translator;\nuse Illuminate\\Contracts\\View\\Factory as ViewFactory;\nuse REBELinBLUE\\Deployer\\Repositories\\Contracts\\DeploymentRepositoryInterface;\nuse REBELinBLUE\\Deployer\\Repositories\\Contracts\\ProjectRepositoryInterface;\n\n/**\n * The dashboard controller.\n */\nclass DashboardController extends Controller\n{\n    /**\n     * @var ViewFactory\n     */\n    private $view;\n\n    /**\n     * @var DeploymentRepositoryInterface\n     */\n    private $deploymentRepository;\n\n    /**\n     * @var ProjectRepositoryInterface\n     */\n    private $projectRepository;\n\n    /**\n     * @var Translator\n     */\n    private $translator;\n\n    /**\n     * DashboardController constructor.\n     *\n     * @param DeploymentRepositoryInterface $deploymentRepository\n     * @param ProjectRepositoryInterface    $projectRepository\n     * @param ViewFactory                   $view\n     * @param Translator                    $translator\n            $projects_by_group[$project->group->name][] = $project;\n        }\n\n        return view('dashboard.index', [\n            'title'    => Lang::get('dashboard.title'),\n            'latest'   => $deploys_by_date,\n        $this->deploymentRepository = $deploymentRepository;\n        $this->projectRepository    = $projectRepository;\n        $this->translator           = $translator;\n    }\n\n    /**\n     * The main page of the dashboard.\n     *\n     * @return \\Illuminate\\View\\View\n     */\n    public function index()\n    {\n        $projects = $this->projectRepository->getAll();\n\n        $projects_by_group = [];\n        foreach ($projects as $project) {\n            if (!isset($projects_by_group[$project->group->name])) {\n                $projects_by_group[$project->group->name] = [];\n            }\n\n            $projects_by_group[$project->group->name][] = $project;\n        }\n\n        ksort($projects_by_group);\n\n        return $this->view->make('dashboard.index', [\n            'title'     => $this->translator->trans('dashboard.title'),\n            'latest'    => $this->buildTimelineData(),\n            'projects'  => $projects_by_group,\n        ]);\n    }\n\n    /**\n     * Returns the timeline.\n     *\n     * @return \\Illuminate\\View\\View\n     */\n    public function timeline()\n    {\n        return $this->view->make('dashboard.timeline', [\n            'latest' => $this->buildTimelineData(),\n        ]);\n    }\n\n    /**\n     * Generates an XML file for CCTray.\n     *\n     * @param ResponseFactory $response\n     *\n     * @return \\Illuminate\\View\\View\n     */\n    public function cctray(ResponseFactory $response)\n    {\n        $projects = $this->projectRepository->getAll();\n\n        foreach ($projects as $project) {\n            $project->latest_deployment = $project->deployments->first();\n        }\n\n        return $response->view('cctray', [\n            'projects' => $projects,\n        ])->header('Content-Type', 'application/xml');\n    }\n\n    /**\n     * Builds the data for the timeline.\n     *\n     * @return array\n     */\n    private function buildTimelineData()\n    {\n        $deployments = $this->deploymentRepository->getTimeline();\n\n        $deploys_by_date = [];\n        foreach ($deployments as $deployment) {\n            $date = $deployment->started_at->format('Y-m-d');\n\n            if (!isset($deploys_by_date[$date])) {\n                $deploys_by_date[$date] = [];\n            }\n\n            $deploys_by_date[$date][] = $deployment;\n        }\n\n        return $deploys_by_date;\n    }\n}\n", 'message': 'Fixes #3 order of projects on dashboard not matching the navigation\n', 'author_name': 'Stephen Ball', 'lang': 'php'}