假设我有一个球员名单
listOfPlayers = [
("Player1","PG",Cost,projectedPoints),
("Player2","PG",Cost,projectedPoints),
("Player3","SG",Cost,projectedPoints),
("Player4","SG",Cost,projectedPoints),
("Player5","SF",Cost,projectedPoints),
("Player6","SF",Cost,projectedPoints),
("Player7","PF",Cost,projectedPoints),
("Player8","PF",Cost,projectedPoints),
("Player9","C",Cost,projectedPoints),
("Player10","C",Cost,projectedPoints)
]
然后是一个空列表
selectedList = []
我需要按位置对球员进行排序,并将最佳成本/预计分数比拉到所选列表中,但问题是我每个位置只能有 1 个,例如 (pg, sg, sf, pf, c) . 我该怎么做?