public function manageMembers($id)
 {
     if (empty(loadGroup($id))) {
         flash()->error('That group does not exist')->important();
         return redirect('groups');
     } else {
         if (!isFounderOfGroup($id, Auth::id())) {
             flash()->error('You must be logged in as the founder of the group in order to manage members.')->important();
             return redirect('groups');
         } else {
             $group = loadGroup($id)[0];
             $members = listUsersOfGroup($group->id);
             $membersRequests = loadGroupMembersRequests($group->id);
             $membersDeclined = loadGroupMembersDeclined($group->id);
             return view('groups.manageMembers', compact('group', 'isMember', 'members', 'membersRequests', 'membersDeclined'));
         }
     }
 }
function MyGroupsSort($asc)
{
    $groups = loadAllGroups();
    $sorted = [];
    for ($i = 0; $i < count($groups); $i++) {
        $next = 0;
        //represents the index
        for ($j = 0; $j < count($groups); $j++) {
            if ($asc == 1) {
                if (count(listUsersOfGroup($groups[$next]->id)) > count(listUsersOfGroup($groups[$j]->id))) {
                    $next = $j;
                }
            } else {
                if ($asc == 0) {
                    if (count(listUsersOfGroup($groups[$next]->id)) < count(listUsersOfGroup($groups[$j]->id))) {
                        $next = $j;
                    }
                }
            }
        }
        array_push($sorted, $groups[$next]);
        array_splice($groups, $next, 1);
        $i--;
    }
    return $sorted;
}