Compare the modifier of two elements

@return -1 if element a has better visibility, 0 if both have the same visibility, +1 if b has
the better visibility. The "best" visibility is PUBLIC
486826
public static int compareModifierVisibility(Element a, Element b) {


    // a better
    if (a.getModifiers().contains(Modifier.PUBLIC) && !b.getModifiers().contains(Modifier.PUBLIC)) {
      return -1;
    }

    if (isDefaultModifier(a.getModifiers()) && !isDefaultModifier(b.getModifiers())) {
      return -1;
    }

    if (a.getModifiers().contains(Modifier.PROTECTED) && !b.getModifiers().contains(Modifier.PROTECTED)) {
      return -1;
    }


    // b better
    if (b.getModifiers().contains(Modifier.PUBLIC) && !a.getModifiers().contains(Modifier.PUBLIC)) {
      return 1;
    }

    if (isDefaultModifier(b.getModifiers()) && !isDefaultModifier(a.getModifiers())) {
      return 1;
    }

    if (b.getModifiers().contains(Modifier.PROTECTED) && !a.getModifiers().contains(Modifier.PROTECTED)) {
      return 1;
    }

    // Same
    return 0;
  }
1080537
@SuppressWarnings("unchecked")
    public static int compare(Object a, Object b) {
        if (a == b) {
            return 0;
        }
        if (a == null) {
            return -1;
        }
        if (b == null) {
            return 1;
        }
        if (a instanceof Comparable) {
            Comparable comparable = (Comparable)a;
            return comparable.compareTo(b);
        }
        int answer = a.getClass().getName().compareTo(b.getClass().getName());
        if (answer == 0) {
            answer = a.hashCode() - b.hashCode();
        }
        return answer;
    }
64643
@Override
  public int compareTo(@Nonnull B other) {
    int length = Math.min(this.getSegments().size(), other.getSegments().size());
    for (int i = 0; i < length; i++) {
      int cmp = this.getSegments().get(i).compareTo(other.getSegments().get(i));
      if (cmp != 0) {
        return cmp;
      }
    }
    return Integer.compare(this.getSegments().size(), other.getSegments().size());
  }
1186092
def compare(a, b):
    
    assertType(a, BigInt)
    b = coerceBigInt(b)
    if not b:
        return NotImplemented

    return librelic.bn_cmp(byref(a), byref(b))
1234004
private ElementUI getVisibleChild(boolean first) {
        int count = getChildCount();
        int start = first ? 0 : count - 1;
        int inc = first ? 1 : -1;
        
        for (int i = start; i >= 0 && i < count; i += inc) {
            ElementUI child = (ElementUI) getChild(i);

            if (child.isVisible()) {
                return child;
            }
        }
        
        return null;
    }
1279352
function compareSpecificity(first, second) {
    for (var i = 0; i < first.length; i++) {
        var a = first[i];
        var b = second[i];

        if (a === b) {
            continue;
        }

        return a - b;
    }

    return 0;
}
1015539
function compare(a, b) {
  invariant(typeof a === typeof b, '"a" and "b" must be of the same type');

  if (a > b) {
    return 1;
  } else if (a < b) {
    return -1;
  } else {
    return 0;
  }
}
160480
def compare_source_offsets(a, b)
      diff = a[0] - b[0]
      diff = a[1] - b[1] if diff == 0

      if diff < 0
        -1
      elsif diff > 0
        1
      else
        0
      end
    end
779792
function(elem, other_elems) {
                    // Pairwise overlap detection
                    var overlapping = function(a, b) {
                        if (Math.abs(2.0*a.offsetLeft + a.offsetWidth - 2.0*b.offsetLeft - b.offsetWidth) < a.offsetWidth + b.offsetWidth) {
                            if (Math.abs(2.0*a.offsetTop + a.offsetHeight - 2.0*b.offsetTop - b.offsetHeight) < a.offsetHeight + b.offsetHeight) {
                                return true;
                            }
                        }
                        return false;
                    };
                    var i = 0;
                    // Check elements for overlap one by one, stop and return false as soon as an overlap is found
                    for(i = 0; i < other_elems.length; i++) {
                        if (overlapping(elem, other_elems[i])) {
                            return true;
                        }
                    }
                    return false;
                }
467302
@Override
    public int compare(final Issue i1, final Issue i2) {

        if (null == i1 && null == i2) {
            return 0;
        } else if (null == i1) {
            return 1;
        } else if (null == i2) {
            return -1;
        } else {
            return i1.getCreatedOn().compareTo(i2.getCreatedOn());
        }
    }
919598
public int compare(final SnomedConcept o1, final SnomedConcept o2) {
        if (o1 == o2) return 0;
        if (o1 != null) {
            if (o2 == null) return 1;
            else return o1.candidatePreferred.compareTo(o2.candidatePreferred);
        }
        return -1;
    }
555262
public static boolean fEq( float a, float b, float epsilon ) {
        if (isNaN(a) && isNaN(b)) {
            return true;
        }
        float diffAbs = abs(a - b);
        return a == b ? true : diffAbs < epsilon ? true : diffAbs / Math.max(abs(a), abs(b)) < epsilon;
    }
466784
private static int div(int a, int b) {
    return a > 0 ? (b > 0 ? a / b : (a - b - 1) / b)
                 : (b > 0 ? (a - b + 1) / b : a / b);
  }
1265343
private static int mod(int a, final int B) {
        final int N = a / B;

        a -= N * B;
        if (a < 0) {
            return a + B;
        }
        return a;
    }
911559
function compareHooks(a, b)
{
  return a.length < b.length ? -1 : (a.length > b.length ? 1 : (a < b ? -1 : (a > b ? 1 : 0)));
}
458483
function defaultCompareKeysFunction (a, b) {
  if (a < b) { return -1; }
  if (a > b) { return 1; }
  if (a === b) { return 0; }

  var err = new Error("Couldn't compare elements");
  err.a = a;
  err.b = b;
  throw err;
}
99614
public boolean greaterThanOrEqual(Object left, Object right) {
    if (left == right) {
      return true;
    }
    else if (left == null || right == null) {
      return false;
    }
    else {
      return compare(left, right, ">=") >= 0;
    }
  }