public int compareTo(Object o) {
            if (!(o instanceof Segment)) {
                return -1;
            }
            
            Segment s = (Segment) o;
        
            // if regions overlap at all, declare the segments equal,
            // to avoid overlap in the segment list
            if (((s.endCode >= startCode) && (s.endCode <= endCode)) ||
                ((s.startCode >= startCode) && (s.startCode <= endCode))) {
                return 0;
            } if (endCode > s.endCode) {
                return 1;
            } else if (endCode < s.endCode) {
                return -1;
            } else {
                return 0;
            }
        }