sortedDescending

@JvmName(name = "sortedDescendingFieldReceiver")
open fun <Context : Any, T> Field<Context, Collection<T>>.sortedDescending(): Value<Context, List<T>>(source)
@JvmName(name = "sortedDescendingPropertyReceiver")
open fun <Context : Any, T> KProperty1<Context, Collection<T>>.sortedDescending(): Value<Context, List<T>>(source)
@JvmName(name = "sortedDescendingResultReceiver")
open fun <Context : Any, T> Collection<T>.sortedDescending(): Value<Context, List<T>>(source)

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

Sort by fields of elements.

Sort by fields of elements.