private SortingAndPaging buildSortAndPage( Integer limit, Integer start, String sort, String sortDirection) { String sortConfigured = sort == null ? "dp.lastName" : "dp." + sort; if (sortConfigured.equals("dp.coach")) { sortConfigured = "dp.coachLastName"; } else if (sortConfigured.equals("dp.currentProgramStatusName")) { sortConfigured = "dp.programStatusName"; } else if (sortConfigured.equals("dp.numberOfEarlyAlerts")) { sortConfigured = "dp.activeAlertsCount"; } else if (sortConfigured.equals("dp.studentType")) { sortConfigured = "dp.studentTypeName"; } SortingAndPaging sortAndPage = SortingAndPaging.createForSingleSortWithPaging( ObjectStatus.ALL, start, limit, sortConfigured, sortDirection, "dp.lastName"); if (sortConfigured.equals("dp.coachLastName")) { sortAndPage.prependSortField( "dp.coachFirstName", SortDirection.getSortDirection(sortDirection)); } return sortAndPage; }