Repository navigation
ThenByDecending
Dennis Corvers edited this page Oct 23, 2026
·
2 revisions
Adds a descending sort criterion after the criteria of a previous sort.
ordered = source:sortBy(primarySelector):thenByDecending(selector)| Parameter | Type | Description |
|---|---|---|
selector |
function(value) |
Returns the next descending sort key. |
The sorted Enumerable, with the additional criterion appended.
The method is spelled thenByDecending in the current API. Call it on an
Enumerable returned by a sort method or another chained sort criterion.
local players = {
{ name = "Ada", role = "mage", damage = 1200 },
{ name = "Cato", role = "mage", damage = 950 },
{ name = "Bryn", role = "ranger", damage = 870 },
}
local ordered = LuaQ.from(players)
:sortBy(function(player) return player.role end)
:thenByDecending(function(player) return player.damage end)
:map(function(player) return player.name end)
:toTable()
-- Orders roles ascending, then damage descending- 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