Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
344 B
5
Indexable
Never
def get_sorted_agents_list(self, order, availableAgents):
        sortedAgentsTuple = []
        for agent in availableAgents:
            dist = math.dist(order.pos, agent.pos)
            sortedAgentsTuple.append((dist, agent))
        sortedAgentsTuple.sort(key= lambda x: x[0])
        return [agent[1] for agent in sortedAgentsTuple]