Description: Sort elements in the PDF output to make it reproducible.
Author: Stuart Prescott <stuart@debian.org>
Forwarded: https://github.com/pyx-project/pyx/pull/3

--- a/pyx/graph/graph.py
+++ b/pyx/graph/graph.py
@@ -526,7 +526,7 @@
             # it is an x-axis
             t = trafo.translate_pt(0, self.ypos_pt + v*self.height_pt - axis.positioner.y1_pt)
         c = canvas.canvas()
-        for layer, subcanvas in list(axis.canvas.layers.items()):
+        for layer, subcanvas in sorted(axis.canvas.layers.items()):
             c.layer(layer).insert(subcanvas, [t])
         assert len(axis.canvas.layers) == len(axis.canvas.items), str(axis.canvas.items)
         axis.canvas = c
@@ -579,8 +579,8 @@
             return
         self.dolayout()
         self.dobackground()
-        for axis in list(self.axes.values()):
-            for layer, canvas in list(axis.canvas.layers.items()):
+        for k, axis in sorted(self.axes.items()):
+            for layer, canvas in sorted(axis.canvas.layers.items()):
                 self.layer("axes.%s" % layer).insert(canvas)
             assert len(axis.canvas.layers) == len(axis.canvas.items), str(axis.canvas.items)
 
--- a/pyx/pdfwriter.py
+++ b/pyx/pdfwriter.py
@@ -105,11 +105,11 @@

     def writeresources(self, file):
         file.write("<<\n")
-        file.write("/ProcSet [ %s ]\n" % " ".join(["/%s" % p for p in list(self.procsets.keys())]))
+        file.write("/ProcSet [ %s ]\n" % " ".join(["/%s" % p for p in sorted(self.procsets.keys())]))
         if self.resources:
-            for resourcetype, resources in list(self.resources.items()):
+            for resourcetype, resources in sorted(self.resources.items()):
                 file.write("/%s <<\n%s\n>>\n" % (resourcetype, "\n".join(["/%s %i 0 R" % (name, self.getrefno(object))
-                                                                          for name, object in list(resources.items())])))
+                                                                          for name, object in sorted(resources.items())])))
         file.write(">>\n")


