在Python中的列表中对嵌套字典进行排序?

时间:2018-05-10 06:23:39

标签: python list dictionary

doSkip: (() => {
  let hasPausedOnce = false;
  return function() {
    XXP.run.removeListener('canper', XXP.Skip);
    XXP.run.currentTime = XXP.skipTo;
    if (!hasPausedOnce) {
      XXP.run.pause();
      hasPausedOnce = true;
    } else XXP.run.play();
  };
})()

我如何根据价格排序??

1 个答案:

答案 0 :(得分:2)

您可以通过应用sorted表达式来使用lambda方法。

sort_list = sorted(data, key=lambda elem: elem['PricingOptions']["Price"])

输出

[{'PricingOptions': {'Price': 51540.72, 'Agents': [4056270]}}, {'PricingOptions': {'Price': 227243.14, 'Agents': [4056270]}}]

如果您希望sort列表下降,您只需将True分配给reverse属性。

相关问题