Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何利用simplejson的item\u sort\u关键特性?_Python_Sorting_Simplejson - Fatal编程技术网

Python 如何利用simplejson的item\u sort\u关键特性?

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

考虑以下json片段:

[
    {
        "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”来实现,但我找不到一个示例来说明如何实现这一点。有人能帮我吗