def _sort_demands(self, _request):
    LOG.debug(' _sort_demands')
    demand_list = []
    open_demand_list = []
    for key in _request.constraints:
        c = _request.constraints[key]
        if (c.constraint_type == 'access_distance'):
            for dk in c.demand_list:
                if (_request.demands[dk].sort_base != 1):
                    _request.demands[dk].sort_base = 1
                    open_demand_list.append(_request.demands[dk])
    for op in _request.objective.operand_list:
        if (op.function.func_type == 'latency_between'):
            if isinstance(op.function.loc_a, demand.Location):
                if (_request.demands[op.function.loc_z.name].sort_base != 1):
                    _request.demands[op.function.loc_z.name].sort_base = 1
                    open_demand_list.append(op.function.loc_z)
            elif isinstance(op.function.loc_z, demand.Location):
                if (_request.demands[op.function.loc_a.name].sort_base != 1):
                    _request.demands[op.function.loc_a.name].sort_base = 1
                    open_demand_list.append(op.function.loc_a)
        elif (op.function.func_type == 'distance_between'):
            if isinstance(op.function.loc_a, demand.Location):
                if (_request.demands[op.function.loc_z.name].sort_base != 1):
                    _request.demands[op.function.loc_z.name].sort_base = 1
                    open_demand_list.append(op.function.loc_z)
            elif isinstance(op.function.loc_z, demand.Location):
                if (_request.demands[op.function.loc_a.name].sort_base != 1):
                    _request.demands[op.function.loc_a.name].sort_base = 1
                    open_demand_list.append(op.function.loc_a)
    if (len(open_demand_list) == 0):
        init_demand = self._exist_not_sorted_demand(_request.demands)
        open_demand_list.append(init_demand)
    while True:
        d_list = self._get_depended_demands(open_demand_list, _request)
        for d in d_list:
            demand_list.append(d)
        init_demand = self._exist_not_sorted_demand(_request.demands)
        if (init_demand is None):
            break
        open_demand_list.append(init_demand)
    return demand_list
def _sort_demands(self, _request):
    LOG.debug(' _sort_demands')
    demand_list = []
    open_demand_list = []
    for key in _request.constraints:
        c = _request.constraints[key]
        if (c.constraint_type == 'access_distance'):
            for dk in c.demand_list:
                if (_request.demands[dk].sort_base != 1):
                    _request.demands[dk].sort_base = 1
                    open_demand_list.append(_request.demands[dk])
    for op in _request.objective.operand_list:
        if (op.function.func_type == 'latency_between'):
            if isinstance(op.function.loc_a, demand.Location):
                if (_request.demands[op.function.loc_z.name].sort_base != 1):
                    _request.demands[op.function.loc_z.name].sort_base = 1
                    open_demand_list.append(op.function.loc_z)
            elif isinstance(op.function.loc_z, demand.Location):
                if (_request.demands[op.function.loc_a.name].sort_base != 1):
                    _request.demands[op.function.loc_a.name].sort_base = 1
                    open_demand_list.append(op.function.loc_a)
        elif (op.function.func_type == 'distance_between'):
            if isinstance(op.function.loc_a, demand.Location):
                if (_request.demands[op.function.loc_z.name].sort_base != 1):
                    _request.demands[op.function.loc_z.name].sort_base = 1
                    open_demand_list.append(op.function.loc_z)
            elif isinstance(op.function.loc_z, demand.Location):
                if (_request.demands[op.function.loc_a.name].sort_base != 1):
                    _request.demands[op.function.loc_a.name].sort_base = 1
                    open_demand_list.append(op.function.loc_a)
    if (len(open_demand_list) == 0):
        init_demand = self._exist_not_sorted_demand(_request.demands)
        open_demand_list.append(init_demand)
    while True:
        d_list = self._get_depended_demands(open_demand_list, _request)
        for d in d_list:
            demand_list.append(d)
        init_demand = self._exist_not_sorted_demand(_request.demands)
        if (init_demand is None):
            break
        open_demand_list.append(init_demand)
    return demand_list