code: private void sortGrantsByStartTime(List<ResourceGrant> grants) {
      Collections.sort(grants, new Comparator<ResourceGrant>() {
        @Override
        public int compare(ResourceGrant g1, ResourceGrant g2) {
          if (g1.grantedTime < g2.grantedTime) {
            return 1;
          }
          if (g1.grantedTime > g2.grantedTime) {
            return -1;
          }
          return g2.id - g1.id;
        }
      });
    }
docs: Sort grants on granted time in descending order
  @param grants the list of grants to sort