code: public List<Order> create(OrderBy order) {
          List<Order> list = new ArrayList<>();
  
          for (SortSpecification sort : order.getSort()) {
              if (sort.getSortOrder() == SortOrder.DESC) {
                  list.add(cb.desc(root.get(sort.getKey())));
              } else if (sort.getSortOrder() == SortOrder.ASC) {
                  list.add(cb.asc(root.get(sort.getKey())));
              }
          }
  
          return list;
      }
docs: Converts an OrderBy clause to a list of javax.persistence Order instances given a Root and a CriteriaBuilder.
  
  @param order the order by clause
  @return a list of Order instances