Repository navigation
ThenBy
Dennis Corvers edited this page Oct 23, 2026
·
2 revisions
Adds an ascending sort criterion after the criteria of a previous sort.
ordered = source:sortBy(primarySelector):thenBy(selector)| Parameter | Type | Description |
|---|---|---|
selector |
function(value) |
Returns the next ascending sort key. |
The sorted Enumerable, with the additional criterion appended.
Call thenBy on an Enumerable returned by sort, sortDescending,
sortBy, sortByDescending, or another thenBy method. Criteria are
evaluated in the order added.
local players = {
{ name = "Bryn", role = "mage" },
{ name = "Ada", role = "mage" },
{ name = "Cato", role = "ranger" },
}
local ordered = LuaQ.from(players)
:sortBy(function(player) return player.role end)
:thenBy(function(player) return player.name end)
:map(function(player) return player.name end)
:toTable()
-- { "Ada", "Bryn", "Cato" }- Home
- Getting Started
-
Functions
- aggregate
- all
- any
- concat
- contains
- count
- create
- createFrom
- deepCopy
- difference
- elementAt
- elementAtOrDefault
- first
- firstOrDefault
- flatMap
- foreach
- groupBy
- groupByResult
- indexOf
- intersect
- ipairs
- last
- lastOrDefault
- map
- max
- min
- pairs
- sequenceEquals
- single
- singleOrDefault
- sort
- sortBy
- sortByDescending
- sortDescending
- sum
- take
- takeWhile
- thenBy
- thenByDecending
- toLookup
- toMap
- toSet
- toTable
- union
- unique
- where
- zip
- Aliases