Returns a Java {@link Comparator} for {@link Columns} with the same logic as this {@link SortField}.

@return A Java {@link Comparator} for {@link Columns} with the same logic as this {@link SortField}.
500572
public Comparator<Columns> comparator() {
        return new Comparator<Columns>() {
            public int compare(Columns o1, Columns o2) {

                if (o1 == null) {
                    return o2 == null ? 0 : 1;
                }
                if (o2 == null) {
                    return -1;
                }

                Column column1 = o1.getColumn(field);
                Column column2 = o2.getColumn(field);

                if (column1 == null) {
                    return column2 == null ? 0 : 1;
                }
                if (column2 == null) {
                    return -1;
                }

                AbstractType<?> type = column1.getType();
                ByteBuffer value1 = column1.getDecomposedValue();
                ByteBuffer value2 = column2.getDecomposedValue();
                return reverse ? type.compare(value2, value1) : type.compare(value1, value2);
            }
        };
    }
373951
@PublicEvolving
	public TypeComparator<T> createComparator(int[] logicalKeyFields, boolean[] orders, int logicalFieldOffset, ExecutionConfig config) {

		TypeComparatorBuilder<T> builder = createTypeComparatorBuilder();

		builder.initializeTypeComparatorBuilder(logicalKeyFields.length);

		for (int logicalKeyFieldIndex = 0; logicalKeyFieldIndex < logicalKeyFields.length; logicalKeyFieldIndex++) {
			int logicalKeyField = logicalKeyFields[logicalKeyFieldIndex];
			int logicalField = logicalFieldOffset; // this is the global/logical field number
			boolean comparatorAdded = false;

			for (int localFieldId = 0; localFieldId < this.getArity() && logicalField <= logicalKeyField && !comparatorAdded; localFieldId++) {
				TypeInformation<?> localFieldType = this.getTypeAt(localFieldId);
				
				if (localFieldType instanceof AtomicType && logicalField == logicalKeyField) {
					// we found an atomic key --> create comparator
					builder.addComparatorField(
						localFieldId,
						((AtomicType<?>) localFieldType).createComparator(
							orders[logicalKeyFieldIndex],
							config));

					comparatorAdded = true;
				}
				// must be composite type and check that the logicalKeyField is within the bounds
				// of the composite type's logical fields
				else if (localFieldType instanceof CompositeType &&
					logicalField <= logicalKeyField &&
					logicalKeyField <= logicalField + (localFieldType.getTotalFields() - 1)) {
					// we found a compositeType that is containing the logicalKeyField we are looking for --> create comparator
					builder.addComparatorField(
						localFieldId,
						((CompositeType<?>) localFieldType).createComparator(
							new int[]{logicalKeyField},
							new boolean[]{orders[logicalKeyFieldIndex]},
							logicalField,
							config)
					);

					comparatorAdded = true;
				}

				if (localFieldType instanceof CompositeType) {
					// we need to subtract 1 because we are not accounting for the local field (not accessible for the user)
					logicalField += localFieldType.getTotalFields() - 1;
				}
				
				logicalField++;
			}

			if (!comparatorAdded) {
				throw new IllegalArgumentException("Could not add a comparator for the logical" +
					"key field index " + logicalKeyFieldIndex + ".");
			}
		}

		return builder.createTypeComparator(config);
	}
134390
private static Set<String> getIndexedColumnSetForTable(Table table) {
        HashSet<String> columns = new HashSet<>();

        for (Index index : table.getIndexes()) {
            for (ColumnRef colRef : index.getColumns()) {
                columns.add(colRef.getColumn().getTypeName());
            }
        }

        return columns;
    }
1154922
public ArrayList<String> getAllColumns() {
		ArrayList<String> columns = new ArrayList<String>();
		for (String col : columnLookup.keySet()) {
			columns.add(col);
		}
		return columns;
	}
265395
public RowMajorMatrixIterator rowMajorIterator() {
        return new RowMajorMatrixIterator(rows, columns) {
            private long limit = (long) rows * columns;
            private int i = - 1;

            @Override
            public int rowIndex() {
                return i / columns;
            }

            @Override
            public int columnIndex() {
                return i - rowIndex() * columns;
            }

            @Override
            public double get() {
                return Matrix.this.get(rowIndex(), columnIndex());
            }

            @Override
            public void set(double value) {
                Matrix.this.set(rowIndex(), columnIndex(), value);
            }

            @Override
            public boolean hasNext() {
                return i + 1 < limit;
            }

            @Override
            public Double next() {
                if(!hasNext()) {
                    throw new NoSuchElementException();
                }

                i++;
                return get();
            }
        };
    }
600329
public RowMajorMatrixIterator nonZeroRowMajorIterator() {
        return new RowMajorMatrixIterator(rows, columns) {
            private long limit = (long) rows * columns;
            private long i = -1;

            @Override
            public int rowIndex() {
                return (int) (i / columns);
            }

            @Override
            public int columnIndex() {
                return (int) (i - ((i / columns) * columns));
            }

            @Override
            public double get() {
                return SparseMatrix.this.get(rowIndex(), columnIndex());
            }

            @Override
            public void set(double value) {
                SparseMatrix.this.set(rowIndex(), columnIndex(), value);
            }

            @Override
            public boolean hasNext() {
                while (i + 1 < limit) {
                    i++;
                    if (SparseMatrix.this.nonZeroAt(rowIndex(), columnIndex())) {
                        i--;
                        break;
                    }
                }

                return i + 1 < limit;
            }

            @Override
            public Double next() {
                if(!hasNext()) {
                    throw new NoSuchElementException();
                }
                i++;
                return get();
            }
        };
    }
544594
public static Comparator<Level> comparator() {
        return new Comparator<Level>() {
            @Override
            public int compare(Level l1, Level l2) {
                return Integer.compare(l1.intValue(), l2.intValue());
            }
        };
    }
794153
public int getSortColRenderIndex() {
        final ValueExpression veSortBy = getValueExpression(PropertyKeys.sortBy.name());
        if (veSortBy == null) {
            return -1;
        }

        final String sortByExp = veSortBy.getExpressionString();
        int colIdx = 0;
        for (final SheetColumn column : getColumns()) {
            if (!column.isRendered()) {
                continue;
            }

            final ValueExpression veCol = column.getValueExpression(PropertyKeys.sortBy.name());
            if (veCol != null) {
                if (veCol.getExpressionString().equals(sortByExp)) {
                    return colIdx;
                }
            }
            colIdx++;
        }
        return -1;
    }
515028
public static Comparator<MonetaryAmount> sortNumberDesc(){
	        return new Comparator<MonetaryAmount>() {
	            @Override
	            public int compare(MonetaryAmount o1, MonetaryAmount o2) {
	                return sortNumber().compare(o1, o2) * -1;
	            }
	        };
	    }
1328817
public BeanQuery<T> orderBy(String orderByProperty, Comparator propertyValueComparator) {
    this.comparator = new DelegatedSortOrderableComparator(new PropertyComparator(orderByProperty,
        propertyValueComparator));
    return this;
  }
415285
protected Comparator<RequestMapperBean> newComparator()
	{
		return new Comparator<RequestMapperBean>()
		{
			@Override
			public int compare(final RequestMapperBean o1, final RequestMapperBean o2)
			{
				return o1.getCompatibilityScore() - o2.getCompatibilityScore();
			}
		};
	}
542908
@ReplacedBy("com.google.common.collect.Ordering.natural().nullsLast()")
    public static final <T extends Comparable<?>> Comparator<T> comparable ()
    {
        @SuppressWarnings("unchecked") Comparator<T> comp = (Comparator<T>)COMPARABLE;
        return comp;
    }
852768
public SortField[] sortFields() {
        return new SortField[]{new SortField(FIELD_NAME, new FieldComparatorSource() {
            @Override
            public FieldComparator<?> newComparator(String field,
                                                    int hits,
                                                    int sort,
                                                    boolean reversed) throws IOException {
                return new ClusteringKeySorter(ClusteringKeyMapper.this, hits, field);
            }
        })};
    }
743394
public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>> Comparator<Pair<T1, T2>> naturalOrder() {
        return new Comparator<Pair<T1,T2>>() {

            @Override
            public int compare(Pair<T1, T2> lhs, Pair<T1, T2> rhs) {
                return compareTo(lhs, rhs);
            }

        };
	}
1118983
private static Sort getSort(String... columnNames) {
        Sort key = null;
        for (String s : columnNames) {
            if (key == null) {
                key = first(s, Sort.Order.DESCEND);
            } else {
                key.next(s, Sort.Order.DESCEND);
            }
        }
        return key;
    }
86083
public Table sortDescendingOn(String... columnNames) {
        Sort key = getSort(columnNames);
        return sortOn(key);
    }
449333
public Column getColumn(String columnName) {
    if (columnName == null) {
      return null;
    }
    for (Column column : columns) {
      if (columnName.equals(column.getData())) {
        return column;
      }
    }
    return null;
  }