【发布时间】:2020-05-07 21:17:45
【问题描述】:
我已经设置了我的代码,因此它获取了一个 API 并将某些变量输出到一个 .txt 文件中,但我希望它不按字母顺序或任何其他方式排序,而是按优先级顺序,所以如果其中一个变量是 MVP,它会作为 VIP 放在 .txt 的更高位置,80 将高于 20 这是.txt的一个例子
b-88698@alt.com : thegiant20** [10]
e-b77b2@alt.com : Rancher** [1] [VIP]
5-c1eb6@alt.com : dogdad** [4] [VIP]
1-15a1f@alt.com : mb1mi** [0]
5-cd91b@alt.com : shalexa** [18] [MVP_PLUS]
但我想订购它,所以它是这样的
5-cd91b@alt.com : shalexa** [18] [MVP_PLUS]
5-c1eb6@alt.com : dogdad** [4] [VIP]
e-b77b2@alt.com : Rancher** [1] [VIP]
b-88698@alt.com : thegiant20** [10]
1-15a1f@alt.com : mb1mi** [0]
有什么我可以放入的东西可以轻松实现吗?
【问题讨论】:
-
所以首先
MVP_PLUS>MVP>other并在每个看括号之间的数字? 80 和 20 是什么? -
它将是 MVP_PLUS 和 80 > MVP_PLUS 和 20 > MVP > VIP_PLUS > VIP > 80 > 50 > 10 > 0,其中单个数字不是 mvp 或 vip
标签: python list sorting output