public Table sortOn(String... columnNames) {

        Sort key = null;
        List<String> names = columnNames().stream().map(String::toUpperCase).collect(toList());

        for (String columnName : columnNames) {
            Sort.Order order = Sort.Order.ASCEND;
            if (!names.contains(columnName.toUpperCase())) {
                // the column name has been annotated with a prefix.
                // get the prefix which could be - or +
                String prefix = columnName.substring(0, 1);

                // remove - prefix so provided name matches actual column name
                columnName = columnName.substring(1, columnName.length());

                order = getOrder(prefix);
            }

            if (key == null) { // key will be null the first time through
                key = first(columnName, order);
            } else {
                key.next(columnName, order);
            }
        }
        return sortOn(key);
    }
public Table sortOn ( String ... columnNames ) { Sort key = null ; List < String > names = columnNames ( ) . stream ( ) . map ( String :: toUpperCase ) . collect ( toList ( ) ) ; for ( String columnName : columnNames ) { Sort . Order order = Sort . Order . ASCEND ; if ( ! names . contains ( columnName . toUpperCase ( ) ) ) { String prefix = columnName . substring ( 0 , 1 ) ; columnName = columnName . substring ( 1 , columnName . length ( ) ) ; order = getOrder ( prefix ) ; } if ( key == null ) { key = first ( columnName , order ) ; } else { key . next ( columnName , order ) ; } } return sortOn ( key ) ; }
Returns a copy of this table sorted on the given column names, applied in order,
<p>
if column name starts with - then sort that column descending otherwise sort ascending