views.php
<?php
    $events = $events->as_array();
    asort($events);
    foreach($events as $event):   
        // some code comes here
    endforeach;
?>
Above code is used to sort the array in ascending order.I want to sort the array value in ascending order by referring the value in from_time colunm in database,that is the value should order in ascending order with respect to the value in from_time column.The above i tried is sorting the value with respect to id.How to sort it with respect to field(from_time) in database.  
Update:
$events = $events->as_array();   
 function cmp(array $a, array $b) {
    if ($a['event_from_time'] < $b['event_from_time']) {//event_from_time is the db column name
        return -1;
    } else if ($a['event_from_time'] > $b['event_from_time']) {
        return 1;
    } else {
        return 0;
    }
}
 usort($events, 'cmp'); 
I am getting this error "ErrorException [ Recoverable Error ]: Argument 1 passed to cmp() must be an array, object given"  in line "function cmp(array $a, array $b) {".
Thanks
 
     
    