Python-如何对由dict构成的list按字典的某个key值进行排序?

发布于 2022-09-04 08:03:26 字数 1213 浏览 27 评论 0

例如:

[
  { "customer": "Franco", "subTime": "2016-12-19 11:03:23" },
  { "customer": "Franco", "subTime": "2016-12-18 21:18:36" },
  { "customer": "Franco", "subTime": "2016-12-17 10:46:53" },
  { "customer": "Rose", "subTime": "2016-12-16 18:48:40" },
  { "customer": "Franco", "subTime": "2016-12-15 16:49:51" },
  { "customer": "Franco", "subTime": "2015-12-15 15:07:22" },
  { "customer": "Franco", "subTime": "2016-12-14 20:13:36" },
  { "customer": "Franco", "subTime": "2016-12-14 20:01:03" },
  { "customer": "Jackson", "subTime": "2015-12-14 18:00:14" },
  { "customer": "Franco", "subTime": "2016-03-08 10:43:08" },
  { "customer": "Franco", "subTime": "2016-02-23 10:52:48" },
  { "customer": "Jackson", "subTime": "2016-02-16 14:27:43" },
  { "customer": "Franco", "subTime": "2016-01-22 14:10:17" },
  { "customer": "Franco", "subTime": "2016-01-11 16:02:55" },
  { "customer": "Franco", "subTime": "2015-12-17 15:46:05" },
  { "customer": "Ronaldo", "subTime": "2016-06-01 17:55:46" },
  { "customer": "Ronaldo", "subTime": "2016-05-18 17:23:30" },
  { "customer": "Ronaldo", "subTime": "2016-02-26 14:38:07" }
]

我想让上例中的list按 subTime 倒序排列, 该如何实现?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文