You could sort them based on the carbon day constants.
Carbon\Carbon::SUNDAY evaluates to 0, Carbon\Carbon::MONDAY evaluates to 1 all the way to Carbon\Carbon::SATURDAY evaluating to 6.
To programatically get a constant, you can use the constant($string) method.
$data = DB::table('jobs')
->select('day', DB::raw('count(*) as count'))
->groupBy('day')
->get()
->sortBy(function ($job) {
return constant('\Carbon\Carbon::'.strtoupper($job->day));
})
->values()
->toArray();
or using php > 7.4
$data = DB::table('jobs')
->select('day', DB::raw('count(*) as count'))
->groupBy('day')
->get()
->sortBy(fn($job) => constant('\Carbon\Carbon::'.strtoupper($job->day)))
->values()
->toArray();
This should return them in a Sunday to Saturday order.
If you want them ordered Monday to Sunday, you're going to need to tweak it a little.
Instead of
return constant('\Carbon\Carbon::'.strtoupper($job->day))
return (6 + constant('\Carbon\Carbon::'.strtoupper($job->day))) % 7;