use of tech.tablesaw.sorting.comparators.IntComparatorChain in project symja_android_library by axkr.
the class TableSlice method sortOn.
/**
* Sort this view in place without modifying or copying the underlying source table. Unlike {@link
* Table#sortOn(Sort)} which returns a copy of the table, this method sorts the view in place.
*
* @param key to sort on.
*/
public void sortOn(Sort key) {
Preconditions.checkArgument(!key.isEmpty());
if (key.size() == 1) {
IntComparator comparator = SortUtils.getComparator(table, key);
this.sortOrder = sortOn(comparator);
} else {
IntComparatorChain chain = SortUtils.getChain(table, key);
this.sortOrder = sortOn(chain);
}
}
use of tech.tablesaw.sorting.comparators.IntComparatorChain in project symja_android_library by axkr.
the class Table method sortOn.
/**
* Returns a copy of this table sorted using the given sort key.
*
* @param key to sort on.
* @return a sorted copy of this table.
*/
public Table sortOn(Sort key) {
Preconditions.checkArgument(!key.isEmpty());
if (key.size() == 1) {
IntComparator comparator = SortUtils.getComparator(this, key);
return sortOn(comparator);
}
IntComparatorChain chain = SortUtils.getChain(this, key);
return sortOn(chain);
}
use of tech.tablesaw.sorting.comparators.IntComparatorChain in project symja_android_library by axkr.
the class SortUtils method getChain.
/**
* Returns a comparator chain for sorting according to the given key
*/
public static IntComparatorChain getChain(Table table, Sort key) {
Iterator<Map.Entry<String, Sort.Order>> entries = key.iterator();
Map.Entry<String, Sort.Order> sort = entries.next();
Column<?> column = table.column(sort.getKey());
IntComparator comparator = rowComparator(column, sort.getValue());
IntComparatorChain chain = new IntComparatorChain(comparator);
while (entries.hasNext()) {
sort = entries.next();
chain.addComparator(rowComparator(table.column(sort.getKey()), sort.getValue()));
}
return chain;
}
Aggregations