Koleksi grup Laravel dan mengurutkan berdasarkan nilai terbesar

//assuming your collection is called $items

$sorted = $items->groupBy('type')
            ->map(function($group){
              return $group->sortByDesc('probability')->take(1);
            })
            ->flatten(1);
SAMER SAEID