public int compare(Object o1, Object o2)
    {
      final EdgeCrossing a = (EdgeCrossing)o1;
      final EdgeCrossing b = (EdgeCrossing)o2;

      if(a.getAngle() < b.getAngle())
      {
        return -1;
      }

      if(a.getAngle() > b.getAngle())
      {
        return 1;
      }

      // Angles are equal.
      if(a.getAngle() == 0)
      {
        return (a.getY() < b.getY()) ? -1 : (a.getY() > b.getY()) ? 1 : 0;
      }

      if(a.getAngle() == 2)
      {
        return (a.getY() > b.getY()) ? -1 : (a.getY() < b.getY()) ? 1 : 0;
      }

      throw new RuntimeException("No result");
    }