Re: python, sorting a dict/json

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Ed
Date:  
To: Main PLUG discussion list
Subject: Re: python, sorting a dict/json
Hans - have you tried jq?
https://stedolan.github.io/jq/


On Fri, Feb 22, 2019 at 12:21 PM der.hans <> wrote:
>
> moin moin,
>
> I'm trying to sort some data that is currently in json being imported into
> a dict.
>
> It's essentially bibliography information, but without a unique ID.
>
> I mostly want to sort on publication date, but also want to group by
> publication. There could be multiple publications on the same date.
>
> Currently using a json format like:
>
> {
>   "pubs": [
>    {
>     "date": 20190222
>     "title": "a title"
>     "url": "https://some.domain/page.html"
>    },
>    {
>     "date": 20190221
>     "title": "another title"
>     "url": "https://some.other.domain/page.html"
>    }
>   ]
> }

>
> Format can change if that helps.
>
> I want to be able to display items in order. Mostly chronological, but
> also by other details.
>
> Any suggestions for how to sort them for display?
>
> A nice, but not required, feature would be sorting them for saving to disk
> as well.
>
> ciao,
>
> der.hans
> --
> # https://www.LuftHans.com https://www.PhxLinux.org
> # "You want weapons? We're in a library! Books! The best weapons in the
> # world! This room's the greatest arsenal we could have - arm yourselves!"
> # -- the Doctor: Doctor Who, Tooth and Claw, 2006
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> https://lists.phxlinux.org/mailman/listinfo/plug-discuss

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss