I have a function that looks like this
public function dod()
{
$this->load->model('deals');
$unsortedData['deals'] = $this->deals_of_day->get_todays_deals();
$data['deals']=$this->sort_deals_by_expiration_time($unsortedData['deals']);
$this->load_view('admin/dod', $data);
}
Where, $unsortedData['deals'] looks like this:
array (size=3)
0 =>
object(stdClass)[64]
public 'created_at' => string '1515477074' (length=10)
public 'updated_at' => string '1515477074' (length=10)
public 'expirationTime' => string '1515479400' (length=10)
1 =>
object(stdClass)[65]
public 'created_at' => string '1515477075' (length=10)
public 'updated_at' => string '1515477075' (length=10)
public 'expirationTime' => string '1515479400' (length=10)
2 =>
object(stdClass)[66]
public 'created_at' => string '1515477075' (length=10)
public 'updated_at' => string '1515477075' (length=10)
public 'expirationTime' => string '1515479400' (length=10)
I wish $data['deals'] to be a sorted array by expirationTime in ascending order.
For reference I saw this answer for sorting an array of objects , and also I saw this answer but they dont seem to fit my case.
Help me with this. Thanks.