Ich habe dies:Laravel Art auf zusätzliches Feld
$companies = Company::all();
foreach($companies as $company)
{
$company->distance = distance(); // a float type. My custom field.
}
$companies->sort(function ($a, $b){
return strcmp($a->distance, $b->distance);
})->values()->all();
ich auch versucht habe: $companies->sortBy('distance')
und einige andere Wege, die nicht funktionierten.
Jeder hat eine Idee, wie dies zu erreichen ist? Dank