public void getTopTables(Context ctx) {
    String order = ctx.queryParam("order");
    String orderBy = ctx.queryParam("orderBy");
    Integer limit = ctx.queryParamAsClass("limit", Integer.class).getOrDefault(10);
    Preconditions.checkArgument(StringUtils.isNotBlank(order), "order can not be empty");
    Preconditions.checkArgument(StringUtils.isNotBlank(orderBy), "orderBy can not be empty");
    List<OverviewTopTableItem> top10Tables;
    boolean isAsc = "asc".equals(order);
    switch (orderBy) {
      case "tableSize":
        Comparator<OverviewTopTableItem> tableSizeComparator =
            Comparator.comparingLong(OverviewTopTableItem::getTableSize);
        top10Tables = getTopTables(isAsc, tableSizeComparator, limit);
        break;
      case "fileCount":
        Comparator<OverviewTopTableItem> fileCountComparator =
            Comparator.comparingLong(OverviewTopTableItem::getFileCount);
        top10Tables = getTopTables(isAsc, fileCountComparator, limit);
        break;
      case "healthScore":
        // If the table health score of the table has not been calculated,
        // it should be sorted at the end of the list
        Comparator<OverviewTopTableItem> healthScoreComparator =
            Comparator.comparingLong(
                item ->
                    item.getHealthScore() < 0
                        ? (isAsc ? Long.MAX_VALUE : Long.MIN_VALUE)
                        : item.getTableSize());
        top10Tables = getTopTables(isAsc, healthScoreComparator, limit);
        break;
      default:
        throw new IllegalArgumentException("Invalid orderBy: " + orderBy);
    }
    ctx.json(OkResponse.of(top10Tables));
  }
The controller that handles overview page requests.
amoro-ams/src/main/java/org/apache/amoro/server/dashboard/controller/OverviewController.java