public function mayores_valores() { $i = null; $aux = null; $ord = array(); for ($i = 0; $i < $this->n; $i++) { $ord[$i] = new Item($this->bolsa[$i]->getNombre(), $this->bolsa[$i]->getPeso(), $this->bolsa[$i]->getValor()); } for ($i = 0; $i < $this->n - 1; $i++) { if ($ord[$i]->getValor() < $ord[$i + 1]->getValor()) { $aux = new Item($ord[$i]->getNombre(), $ord[$i]->getPeso(), $ord[$i]->getValor()); $ord[$i] = new Item($ord[$i + 1]->getNombre(), $ord[$i + 1]->getPeso(), $ord[$i + 1]->getValor()); $ord[$i + 1] = new Item($aux->getNombre(), $aux->getPeso(), $aux->getValor()); $i = 0; } } return $ord; }