Record Class SortKey
For the default top-to-bottom sort (Range.sort(io.keikai.axyra.sheets.SortKey...)) column
is the range-relative key column; for a left-to-right sort
(Range.sortLeftToRight(io.keikai.axyra.sheets.SortKey...)) it is the range-relative key row.
When customOrder is non-null, values whose text matches a list
entry (case-insensitively) sort by the entry's position; all non-matching
values sort after every matching value, ordered among themselves by the
normal comparator. A descending key produces the exact reverse of the
ascending order.
textAsNumber is Excel's Sort Warning choice "Sort anything that
looks like a number, as a number". Left off — the default, and what Excel's
own Range.Sort does — text that spells a number is ordered by its
characters, so "1" < "10" < "100" < "2". Turned on, such text is
read as its numeric value and interleaves with genuine numeric cells, so
"1" < "2" < "10" < "100".
-
Constructor Summary
ConstructorsConstructorDescriptionSortKey(int column, boolean ascending) A plain key without a custom ordering list.A key with a custom ordering list but the default text ordering.Creates an instance of aSortKeyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic SortKeyasc(int column) Ascending sort on a column.booleanReturns the value of theascendingrecord component.intcolumn()Returns the value of thecolumnrecord component.String[]Returns the value of thecustomOrderrecord component.static SortKeycustomOrder(int column, String... values) Ascending sort on a column by the position of each value invalues(Excel's "Custom Lists" order, e.g.static SortKeydesc(int column) Descending sort on a column.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.A copy of this key that reads numeric-looking text as a number — Excel's "Sort anything that looks like a number, as a number".booleanReturns the value of thetextAsNumberrecord component.final StringtoString()Returns a string representation of this record class.withCustomOrder(String... values) A copy of this key carrying the given custom ordering list.
-
Constructor Details
-
SortKey
A key with a custom ordering list but the default text ordering. -
SortKey
public SortKey(int column, boolean ascending) A plain key without a custom ordering list. -
SortKey
Creates an instance of aSortKeyrecord class.- Parameters:
column- the value for thecolumnrecord componentascending- the value for theascendingrecord componentcustomOrder- the value for thecustomOrderrecord componenttextAsNumber- the value for thetextAsNumberrecord component
-
-
Method Details
-
asc
Ascending sort on a column. -
desc
Descending sort on a column. -
customOrder
Ascending sort on a column by the position of each value invalues(Excel's "Custom Lists" order, e.g."Mon", "Tue", "Wed", ...); unlisted values sort after all listed ones. -
withCustomOrder
A copy of this key carrying the given custom ordering list. -
sortingTextAsNumber
A copy of this key that reads numeric-looking text as a number — Excel's "Sort anything that looks like a number, as a number". -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
column
public int column()Returns the value of thecolumnrecord component.- Returns:
- the value of the
columnrecord component
-
ascending
public boolean ascending()Returns the value of theascendingrecord component.- Returns:
- the value of the
ascendingrecord component
-
customOrder
Returns the value of thecustomOrderrecord component.- Returns:
- the value of the
customOrderrecord component
-
textAsNumber
public boolean textAsNumber()Returns the value of thetextAsNumberrecord component.- Returns:
- the value of the
textAsNumberrecord component
-