I'm having trouble coding. I want to save data from higher value to lower. ex: the $nilai value is 1,2,3,4,5. im need 2 data from higher value $nilai (5,4).
any solutions?
this is my code:
public function savereport()
{
$fuzzyfikasi = $this->seleksi->getFuzzyfikasi();
$maxC1 = $this->hitung->maxC1();
$maxC2 = $this->hitung->maxC2();
$maxC3 = $this->hitung->maxC3();
$maxC4 = $this->hitung->maxC4();
$maxC5 = $this->hitung->maxC5();
$minC1 = $this->hitung->minC1();
$minC2 = $this->hitung->minC2();
$minC3 = $this->hitung->minC3();
$minC4 = $this->hitung->minC4();
$minC5 = $this->hitung->minC5();
$bobotC1 = $this->hitung->bobotC1();
$bobotC2 = $this->hitung->bobotC2();
$bobotC3 = $this->hitung->bobotC3();
$bobotC4 = $this->hitung->bobotC4();
$bobotC5 = $this->hitung->bobotC5();
$i = 1;
foreach ($fuzzyfikasi as $f) :
$i;
$npm = $f['npm'];
$rankC1 = ($f['C1'] / $maxC1['C1']) * $bobotC1['bobot'];
$rankC2 = ($minC2['C2'] / $f['C2']) * $bobotC2['bobot'];
$rankC3 = ($f['C3'] / $maxC3['C3']) * $bobotC3['bobot'];
$rankC4 = ($minC4['C4'] / $f['C4']) * $bobotC4['bobot'];
$rankC5 = ($f['C5'] / $maxC5['C5']) * $bobotC5['bobot'];
$nilai = $rankC1 + $rankC2 + $rankC3 + $rankC4 + $rankC5;
$data = [
'npm' => $npm,
'nilai' => $nilai
];
$this->seleksi->inputreport($data);
if ($i++ == $this->input->post('max')) break;
endforeach;
$this->toastr->success('Saved!');
redirect('admin');
}
I want to save data from higher to lower $nilai (Ranking). help me please. using sort method but its not working. like sort($nilai);