Sort the points in x first, since this is an assumption of the implementation.
Sort the points in x first, since this is an assumption of the implementation.

file:a/voronoi.py -> file:b/voronoi.py
--- a/voronoi.py
+++ b/voronoi.py
@@ -161,6 +161,10 @@
             b=2*(self.edge.rp[0]-self.edge.lp[0])
             c=(self.edge.lp[0]**2+self.edge.lp[1]**2-self.edge.rp[0]**2-self.edge.rp[1]**2)
             x=(self.edge.lp[0]+self.edge.rp[0])/2
+        elif self.edge.rp[1]==point[1]:
+            x=self.edge.rp[0]
+        elif self.edge.lp[1]==point[1]:
+            x=self.edge.lp[0]
         elif self.edge.lp[1]!=self.edge.rp[1]:
             r1=1/(self.edge.lp[1]-point[1])
             r2=1/(self.edge.rp[1]-point[1])
@@ -297,9 +301,18 @@
 
 class Voronoi:
     def __init__(self,points,width,height):
-        self.points=points
         self.width=width
         self.height=height
+
+        # Sort the points in x first
+        self.points=[]
+        for point in points:
+            insert=len(self.points)
+            for idx in range(0,len(self.points)):
+                if self.points[idx][0]>point[0]:
+                    insert=idx
+                    break
+            self.points.insert(insert,point)
 
     def edges(self):
         self.root=None
@@ -408,7 +421,7 @@
         edge_to_end2=circle_node.first_right_parent().edge
         t,s=edge_to_end1.intersects_with(edge_to_end2)
         
-        print 't,s',t,s
+#        print 't,s',t,s
         if (t<0 and edge_to_end1.start!=None) or (s<0 and edge_to_end2.start!=None):
             return