I have an array like below,
[{
   "name":"Daniel",
   "connection_status":"1"
   },
 {
   "name":"Danny",
   "connection_status":"3"
   },
   {
   "name":"Moris",
   "connection_status":"2"
   },
   {
   "name":"Manny",
   "connection_status":"1"
   }]
I want to sort my array by status like 1,2,3 in this order. This is my code,
 public function getProfileDataForMySociety($user_id) 
    {
        $this->db->select('*');
        $this->db->from('profile');
        $this->db->where('profile_id!=', $user_id);
        $query = $this->db->get();
        $list = $query->result();
        $friends = $this->checkFriends($list, $user_id);
        return $friends;
    }
  public function checkFriends($list, $user_id) 
{
    $array = [];
    foreach ($list as $k => $v) {
        //     print_r(json_encode($list));
        $friends = $this->checkStatus($v->profile_id);
        //print_r($friends);
        $relationship = '';
        $relation_id = '';
        foreach ($friends as $kk => $vv) {
            if ($user_id == $vv->sent_id) {
                if ($vv->status == 1) {
                    $relationship = 1;
                }
                if ($vv->status == 2) {
                    $relationship = 2;
                }
            } else if ($user_id == $vv->recieved_id) {
                // pending
                if ($vv->status == 1) {
                    $relationship = 3;
                    $relation_id = $vv->sent_id;
                }
                if ($vv->status == 2) {
                    $relationship = 4;
                }
            }
        }
        $list[$k]->connection_status = $relationship;
        $list[$k]->relation_id = $relation_id;
    }
    return $list;
}
public function checkStatus($id) 
{
    $this->db->select('*');
    $this->db->from('requests');
    $this->db->where('sent_id', $id);
    $this->db->or_where('recieved_id', $id);
    $query = $this->db->get();
    $list = $query->result();
    return $list;
}
connection status is not a db field. Where $list is my o/p array.Can anyone help me.Thanks in advance. I want to sort my array based on my connection_status.
 
     
     
    