Sort and return crons list.

@return CronInterface[] crons list
351851
public function getCrons(): array
    {
        ksort($this->crons);
        $crons = [];

        foreach ($this->crons as $priority => $cs) {
            foreach ($cs as $cron) {
                $crons[$priority . ';' . $cron->getAlias()] = $cron;
            }
        }

        return $crons;
    }
927679
public function getSorting()
    {
        $sortOrder = $this->getRequest()->get('sortOrder', 'asc');
        $sortBy = $this->getRequest()->get('sortBy', 'id');

        return [$sortBy => $sortOrder];
    }
13088
private function prepareSortOrders()
    {
        $sortOrders = [];

        foreach ($this->_orders as $attribute => $direction) {
            $sortParams = ['direction' => $direction];
            $sortField = $attribute;
            $sortOrders[$sortField] = $sortParams;
        }

        return $sortOrders;
    }
885920
protected function getOrderedByDistanceAsc(): array
    {
        $values = $this->getIndexedValues();
        uksort($values, function ($oneDistanceInMeters, $anotherDistanceInMeters) {
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
            $oneDistanceInMeters = ToFloat::toPositiveFloat($oneDistanceInMeters);
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
            $anotherDistanceInMeters = ToFloat::toPositiveFloat($anotherDistanceInMeters);

            return $oneDistanceInMeters <=> $anotherDistanceInMeters; // lowest first
        });

        return $values;
    }
150075
public function getTasks()
    {
        $tasks = [];

        foreach ($this->getKernelEvents() as $event) {
            $tasks[] = [
                'task'          => $this->formatTask($event),
                'expression'    => $event->expression,
                'nextRunDate'   => $event->nextRunDate()->format('Y-m-d H:i:s'),
                'description'   => $event->description,
                'readable'      => CronSchedule::fromCronString($event->expression)->asNaturalLanguage(),
            ];
        }

        return $tasks;
    }
1346863
public function listJobs($crontab){

        $process = new Process($this->crontabCommand($crontab).' -l');
        $process->run();

        $this->error = $process->getErrorOutput();
        return $process->getOutput();

    }
894084
public function fetchAll() {
        $crontab = $this->_exec('crontab -l');
        $crontab = trim($crontab);
        if (preg_match('/no crontab for/', $crontab)) {
            return null;
        } else {
            $cronjobs = explode("\n", $crontab);
            return $cronjobs;
        }
    }
558465
public function listAction()
    {
        $this->performAccessChecks();

        $crons = $this->cronService->getCrons();

        return $this->render('SmileEzUICronBundle:cron:tab/crons/list.html.twig', [
            'datas' => $crons
        ]);
    }
776035
static function statusNameMap()
    {
        return array( self::STATUS_NONE => ezpI18n::tr( 'kernel/classes', 'No state yet' ),
                      self::STATUS_ACCEPTED => ezpI18n::tr( 'kernel/classes', 'Accepted event' ),
                      self::STATUS_REJECTED => ezpI18n::tr( 'kernel/classes', 'Rejected event' ),
                      self::STATUS_DEFERRED_TO_CRON => ezpI18n::tr( 'kernel/classes', 'Event deferred to cron job' ),
                      self::STATUS_DEFERRED_TO_CRON_REPEAT => ezpI18n::tr( 'kernel/classes', 'Event deferred to cron job, event will be rerun' ),
                      self::STATUS_RUN_SUB_EVENT => ezpI18n::tr( 'kernel/classes', 'Event runs a sub event' ),
                      self::STATUS_WORKFLOW_CANCELLED => ezpI18n::tr( 'kernel/classes', 'Canceled whole workflow' ),
                      self::STATUS_WORKFLOW_RESET => ezpI18n::tr( 'kernel/classes', 'Workflow was reset for reuse' ) );
    }
709164
public function sortByEndDate()
	{
		uksort( $this->contexts, function( $a, $b ) use ( &$contexts )
		{
			return -1 * strcmp( $this->contexts[ $a] ['period']['endDate'], $this->contexts[ $b]['period']['endDate'] );
		} );

		return $this;
	}
176020
private function getScheduleThreshold()
    {
        $hour = $this->app['config']->get('general/cron_hour', '03:00');

        if (is_numeric($hour)) {
            $hour .= ':00';
        }

        $this->cronHour = new \DateTime($hour);
    }
10868
public function index()
    {
        return [
            'jobsPerMinute' => app(MetricsRepository::class)->jobsProcessedPerMinute(),
            'processes' => $this->totalProcessCount(),
            'queueWithMaxRuntime' => app(MetricsRepository::class)->queueWithMaximumRuntime(),
            'queueWithMaxThroughput' => app(MetricsRepository::class)->queueWithMaximumThroughput(),
            'recentlyFailed' => app(JobRepository::class)->countRecentlyFailed(),
            'recentJobs' => app(JobRepository::class)->countRecent(),
            'status' => $this->currentStatus(),
            'wait' => collect(app(WaitTimeCalculator::class)->calculate())->take(1),
            'periods' => [
                'recentJobs' => config('horizon.trim.recent'),
                'recentlyFailed' => config('horizon.trim.failed'),
            ],
        ];
    }
775458
public function getScheduleDelay()
    {
        $value = $this->getSchedule();
        if (null === $value) {
            return -1;
        }

        $object = CronExpression::factory($value);

        $format = 'Y-m-d H:i:s';
        $timeFirst = strtotime($object->getNextRunDate()->format($format));
        $timeSecond = strtotime(date($format));

        return (int) $timeFirst - $timeSecond;
    }
753920
public function getSortedCellList()
    {
        $sortKeys = array();
        foreach ($this->getCellList() as $coord) {
            sscanf($coord, '%[A-Z]%d', $column, $row);
            $sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
        }
        ksort($sortKeys);

        return array_values($sortKeys);
    }
713612
public function listAction()
    {
        $this->performAccessChecks();

        $crons = $this->cronService->listCronsStatus();
        $cronRows = array();

        foreach ($crons as $cron) {
            $cronRows[] = array(
                'alias' => $cron->getAlias(),
                'queued' => $cron instanceof SmileCron
                    ? ($cron->getQueued() ? $cron->getQueued()->format('d-m-Y H:i') : false)
                    : false,
                'started' => $cron instanceof SmileCron ? ($cron->getStarted()
                    ? $cron->getStarted()->format('d-m-Y H:i') : false)
                    : false,
                'ended' => $cron instanceof SmileCron ? ($cron->getEnded()
                    ? $cron->getEnded()->format('d-m-Y H:i') : false)
                    : false,
                'status' => $cron instanceof SmileCron ? $cron->getStatus() : false
            );
        }

        return $this->render('SmileEzUICronBundle:cron:tab/status/list.html.twig', [
            'datas' => $cronRows
        ]);
    }
696568
private function getRunTimes()
    {
        foreach (array_keys($this->jobs) as $interimName) {
            if (!$runEntity = $this->repository->getNextRunTime($interimName)) {
                $epoch = new \DateTime();
                $epoch->setTimestamp(0);
                $runEntity = new Entity\Cron(['interim' => $interimName, 'lastrun' => $epoch]);
            }

            $this->jobs[$interimName]['entity'] = $runEntity;
            $this->jobs[$interimName]['lastRunTime'] = $runEntity->getLastrun();
            $this->jobs[$interimName]['nextRunTime'] = $this->getNextRunTime($interimName, $runEntity);
        }
    }
567335
public function getScheduledJobs()
    {
        $jobs = [];
        foreach ($this->jobs as $job) {
            $model = CronJob::find($job['id']);

            // create a new model if this is the job's first run
            if (!$model) {
                $model = new CronJob();
                $model->id = $job['id'];
                $model->save();
            }

            // check if scheduled to run
            $params = new DateParameters($job);
            $date = new CronDate($params, $model->last_ran);

            if ($date->getNextRun() > time()) {
                continue;
            }

            $job = array_replace([
                'successUrl' => '',
                'expires' => 0,
            ], $job);

            $job['model'] = $model;
            $jobs[] = $job;
        }

        return $jobs;
    }