Record Class SortKey
- Record Components:
column- the 0-based key index relative to the range: a column forRange.sort(io.keikai.axyra.sheets.SortKey...), a row forRange.sortLeftToRight(io.keikai.axyra.sheets.SortKey...)ascending-truefor A to Z, smallest firstcustomOrder- the custom ordering list, ornullfor the normal order; stored as given, not copiedtextAsNumber-trueto sort numeric-looking text as numbers
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) Creates a plain key: no custom ordering list,textAsNumberoff.Creates a key with a custom ordering list andtextAsNumberoff.Creates an instance of aSortKeyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic SortKeyasc(int column) Returns an ascending key oncolumn.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) Returns a descending key oncolumn.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns 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) Returns a copy of this key with the given custom ordering list.
-
Constructor Details
-
SortKey
Creates a key with a custom ordering list andtextAsNumberoff.- Parameters:
column- the 0-based key index relative to the rangeascending-truefor A to Z, smallest firstcustomOrder- the custom ordering list, ornull
-
SortKey
public SortKey(int column, boolean ascending) Creates a plain key: no custom ordering list,textAsNumberoff.- Parameters:
column- the 0-based key index relative to the rangeascending-truefor A to Z, smallest first
-
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
Returns an ascending key oncolumn.- Parameters:
column- the 0-based key index relative to the range
-
desc
Returns a descending key oncolumn.- Parameters:
column- the 0-based key index relative to the range
-
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. Matching ignores case.- Parameters:
column- the 0-based key index relative to the rangevalues- the list entries in sort order; copied
-
withCustomOrder
Returns a copy of this key with the given custom ordering list. The direction andtextAsNumberare kept.- Parameters:
values- the list entries in sort order; copied
-
sortingTextAsNumber
Returns 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
-