Пример #1
0
  private static void sortByLastPushedDateAndName(List<Project> projects) {
    Collections.sort(
        projects,
        new Comparator<Project>() {
          @Override
          public int compare(Project p1, Project p2) {
            int compareLastPushedDate = 0;
            if (p1.lastPushedDate == null && p2.lastPushedDate == null) {
              return p1.name.compareTo(p2.name);
            }

            if (p1.lastPushedDate == null) {
              return 1;
            } else if (p2.lastPushedDate == null) {
              return -1;
            }

            compareLastPushedDate = p2.lastPushedDate.compareTo(p1.lastPushedDate);
            if (compareLastPushedDate == 0) {
              return p1.name.compareTo(p2.name);
            }
            return compareLastPushedDate;
          }
        });
  }
Пример #2
0
  private static void sortDatum(
      List<Posting> postings,
      List<Issue> issues,
      List<PullRequest> pullRequests,
      List<Milestone> milestones) {

    Collections.sort(
        issues,
        new Comparator<Issue>() {
          @Override
          public int compare(Issue i1, Issue i2) {
            return i2.createdDate.compareTo(i1.createdDate);
          }
        });

    Collections.sort(
        postings,
        new Comparator<Posting>() {
          @Override
          public int compare(Posting p1, Posting p2) {
            return p2.createdDate.compareTo(p1.createdDate);
          }
        });

    Collections.sort(
        pullRequests,
        new Comparator<PullRequest>() {
          @Override
          public int compare(PullRequest p1, PullRequest p2) {
            return p2.created.compareTo(p1.created);
          }
        });

    Collections.sort(
        milestones,
        new Comparator<Milestone>() {
          @Override
          public int compare(Milestone m1, Milestone m2) {
            return m2.title.compareTo(m1.title);
          }
        });
  }