code: public static Sort toSort(ComparatorItem comparatorItem) {
      List<Sort.Order> orderList = new LinkedList<>();
      ComparatorItem item = comparatorItem;
      Sort.Order order;
      while ((order = toSortOrder(item)) != null) {
        orderList.add(order);
        item = item.getNextComparatorItem();
      }
      if (orderList.isEmpty()) {
        return null;
      }
      return Sort.by(orderList);
    }
docs: Transforms the comparator item into a {@code Sort} object.
  
  @param comparatorItem the comparator item
  @return the sort object