make index generation fully reproducible
To make index tests much easier and to improve the effectiveness of the index compression, the lists, sets, and dicts should be sorted as much as is feasible. This is already the case with index.xml, indeed there is a test that runs every time that checks whether the output has changed at all. We need this now for index-v1.json.
Python3's collections provides OrderedDict, which is helpful, but no OrderedSet. There are a few things that need to be handled using sets. I found the sortedcollections which is available starting with Debian/jessie and Ubuntu/xenial for a while, so it seems like a easy library to use. It also seems to have good performance: http://www.grantjenks.com/docs/sortedcontainers/performance.html