sorted
open fun <Context : Any, T> KProperty1<Context, Collection<T>>.sorted(): Value<Context, List<T>>(source)
Sorts an array based on its elements, in ascending order.
Example
class Player(
val _id: ObjectId,
val scores: List<Int>,
val worstScores: List<Int>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sorted()
.take(5)
}
}
Content copied to clipboard
External resources
See also
Sort by fields of elements.
Sort by elements in descending order.