code: private Page<Alert> preparePage(List<Alert> alerts, Pager pager) {
          if (pager != null) {
              if (pager.getOrder() != null
                      && !pager.getOrder().isEmpty()
                      && pager.getOrder().get(0).getField() == null) {
                  pager = Pager.builder()
                          .withPageSize(pager.getPageSize())
                          .withStartPage(pager.getPageNumber())
                          .orderBy(AlertComparator.Field.ALERT_ID.getText(), Order.Direction.DESCENDING).build();
              }
              List<Alert> ordered = alerts;
              if (pager.getOrder() != null) {
                  pager.getOrder().stream()
                          .filter(o -> o.getField() != null && o.getDirection() != null)
                          .forEach(o -> {
                              AlertComparator comparator = new AlertComparator(o.getField(), o.getDirection());
                              Collections.sort(ordered, comparator);
                          });
              }
              if (!pager.isLimited() || ordered.size() < pager.getStart()) {
                  pager = new Pager(0, ordered.size(), pager.getOrder());
                  return new Page<>(ordered, pager, ordered.size());
              }
              if (pager.getEnd() >= ordered.size()) {
                  return new Page<>(ordered.subList(pager.getStart(), ordered.size()), pager, ordered.size());
              }
              return new Page<>(ordered.subList(pager.getStart(), pager.getEnd()), pager, ordered.size());
          } else {
              AlertComparator.Field defaultField = AlertComparator.Field.ALERT_ID;
              Order.Direction defaultDirection = Order.Direction.ASCENDING;
              AlertComparator comparator = new AlertComparator(defaultField.getText(), defaultDirection.ASCENDING);
              pager = Pager.builder().withPageSize(alerts.size()).orderBy(defaultField.getText(), defaultDirection)
                      .build();
              Collections.sort(alerts, comparator);
              return new Page<>(alerts, pager, alerts.size());
          }
      }
docs: Private methods