code: @SuppressWarnings("unchecked")
      public static int compareNumber(Object first, Number second) {
          if (first instanceof Number && first instanceof Comparable &&
              first.getClass().equals(second.getClass())) {
              return ((Comparable<Number>) first).compareTo(second);
          }
  
          Function<Object, BigDecimal> toBig = (number) -> {
              try {
                  return new BigDecimal(number.toString());
              }
docs: Compare object with a number, the object should be a number,
  or it can be converted to a BigDecimal
  @param first   might be number or string
  @param second  must be number
  @return  0 if first is numerically equal to second;
  a negative int if first is numerically less than second;
  a positive int if first is numerically greater than second.