@SuppressWarnings("unchecked")
    private int compareValues(Object val1, Object val2) {

      if (val1 == null || val2 == null) {
        return val1 == null && val2 == null ? 0 : val1 == null ? -1 : 1;
      }

      if (val1 instanceof Comparable) {
        try {
          return ((Comparable) val1).compareTo(val2);
        } catch (ClassCastException e) {
          return 0;
        }
      }
      return 0;
    }
Sort by properties.
@param sortRequest @SortRequest to sort by.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java