Iterable<Map.Entry<String,Sort.Order>>
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 | Description |
---|---|---|
static class |
Sort.Order |
Constructor | Description |
---|---|
Sort(String columnName,
Sort.Order order) |
Constructs a Sort specifying the order (ascending or descending) to apply to the column with
the given name
|
Modifier and Type | Method | Description |
---|---|---|
static Sort |
create(Table table,
String... columnNames) |
Create a Sort object from the given table and sort column names.
|
boolean |
isEmpty() |
Returns true if no order has been set
|
Iterator<Map.Entry<String,Sort.Order>> |
iterator() |
Returns an iterator over elements of type
T . |
Sort |
next(String columnName,
Sort.Order order) |
Returns a Sort that concatenates a new sort on the given order (ascending or descending) and
columnName onto the sort specified here.
|
static Sort |
on(String columnName,
Sort.Order order) |
Returns a Sort specifying the order (ascending or descending) to apply to the column with the
given name
|
int |
size() |
Returns the number of columns used in this sort
|
String |
toString() |
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 © 2022. All rights reserved.