Python 如何利用simplejson的item\u sort\u关键特性?
考虑以下json片段:Python 如何利用simplejson的item\u sort\u关键特性?,python,sorting,simplejson,Python,Sorting,Simplejson,考虑以下json片段: [ { "starts_at": "2015-09-14 01:07:52", "created_at": "2015-09-15 00:03:19", "guid": "335eccaa689c480a91bff731712250d9" }, { "guid": "13f0e832fd0404170ae7501c288d6708", "created_at": "20
[
{
"starts_at": "2015-09-14 01:07:52",
"created_at": "2015-09-15 00:03:19",
"guid": "335eccaa689c480a91bff731712250d9"
},
{
"guid": "13f0e832fd0404170ae7501c288d6708",
"created_at": "2015-09-16 00:03:21",
"starts_at": "2015-09-15 00:03:19"
}
]
我需要能够按照“guid”进行排序,因此在本例中,我应该得到以下结果:
[
{
"guid": "13f0e832fd0404170ae7501c288d6708",
"created_at": "2015-09-16 00:03:21",
"starts_at": "2015-09-15 00:03:19"
},
{
"starts_at": "2015-09-14 01:07:52",
"created_at": "2015-09-15 00:03:19",
"guid": "335eccaa689c480a91bff731712250d9"
}
]
我使用jq'sort_by(.guid)
实现了这一点,但我需要使用python。我知道这可以通过将item\u sort\u key
设置为“guid”来实现,但我找不到一个示例来说明如何实现这一点。有人能帮我吗