public int compareTo(Segment o) {
            if(this.direction != o.direction){
                if(this.direction == Direction.VERTICAL) return 1; else return -1;
            } else{
                if(this.direction == Direction.HORIZONTAL){
                    if(this.start.y != o.start.y) return (this.start.y - o.start.y);
                    if(this.start.x != o.start.x) return (this.start.x - o.start.x);
                    return (this.end.x - o.end.x);
                } else{
                    if(this.start.x != o.start.x) return (this.start.x - o.start.x);
                    if(this.start.y != o.start.y) return (this.start.y - o.start.y);
                    return (this.end.y - o.end.y);
                }
            }
        }