MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation.operators • ArrayValueOperators • sortedDescending
sortedDescending¶
Sorts an array based on its elements, in descending order.
Example¶
class Player(
val _id: ObjectId,
val scores: List<Int>,
val bestScores: List<Int>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedDescending()
.take(5)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by fields of elements.
Sorts an array based on its elements, in descending order.
Example¶
class Player(
val _id: ObjectId,
val scores: List<Int>,
val bestScores: List<Int>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedDescending()
.take(5)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by fields of elements.
open fun <Context : Any, T> KProperty1<Context, Collection<T>>.sortedDescending(): Value<Context, List<T>>
Sorts an array based on its elements, in descending order.
Example¶
class Player(
val _id: ObjectId,
val scores: List<Int>,
val bestScores: List<Int>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedDescending()
.take(5)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by fields of elements.
open fun <Context : Any, T> Collection<T>.sortedDescending(): Value<Context, List<T>>
Sorts an array based on its elements, in descending order.
Example¶
class Player(
val _id: ObjectId,
val scores: List<Int>,
val bestScores: List<Int>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedDescending()
.take(5)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by fields of elements.