code: public static String converToOrderBySql(String sql, String orderBy) {
          //解析SQL
          Statement stmt = null;
          try {
              stmt = CCJSqlParserUtil.parse(sql);
              Select select = (Select) stmt;
              SelectBody selectBody = select.getSelectBody();
              //处理body-去最外层order by
              List<OrderByElement> orderByElements = extraOrderBy(selectBody);
              String defaultOrderBy = PlainSelect.orderByToString(orderByElements);
              if (defaultOrderBy.indexOf('?') != -1) {
                  throw new PageException("原SQL[" + sql + "]中的order by包含参数，因此不能使用OrderBy插件进行修改!");
              }
              //新的sql
              sql = select.toString();
          } catch (Throwable e) {
              throw new PageException("处理排序失败: " + e, e);
          }
          return sql + " order by " + orderBy;
      }
docs: convert to order by sql
  
  @param sql
  @param orderBy
  @return