public class Sort extends Object implements Iterable<Map.Entry<String,Sort.Order>>
Use:
table.sortOn(first("Year", DESCEND).next("State", ASCEND));
This sorts table on the column named year in descending order, such that the most recent years appear first, then on State, in ascending order so "AL" will appear before "CA". You can add additional instructions for multi-column sorts by chaining additional calls to next() with the appropriate column names and Order.
Modifier and Type | Class and Description |
---|---|
static class |
Sort.Order |
Constructor and Description |
---|
Sort(String columnName,
Sort.Order order) |
Modifier and Type | Method and Description |
---|---|
static Sort |
create(Table table,
String... columnNames)
Create a Sort object from the given table and sort column names.
|
boolean |
isEmpty() |
Iterator<Map.Entry<String,Sort.Order>> |
iterator()
Returns an iterator over elements of type
T . |
Sort |
next(String columnName,
Sort.Order order) |
static Sort |
on(String columnName,
Sort.Order order) |
int |
size() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public Sort(String columnName, Sort.Order order)
public static Sort on(String columnName, Sort.Order order)
public Sort next(String columnName, Sort.Order order)
public boolean isEmpty()
public int size()
public static Sort create(Table table, String... columnNames)
table
- to sort. Used only to pull the table's schema. Does not modify the table.columnNames
- The columns to sort on. Can prefix column name with + for ascending, - for
descending. Default to ascending if no prefix is added.Sort(java.lang.String, tech.tablesaw.sorting.Sort.Order)
Object.public Iterator<Map.Entry<String,Sort.Order>> iterator()
T
.iterator
in interface Iterable<Map.Entry<String,Sort.Order>>
Copyright © 2020. All rights reserved.