MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation.operators • ArrayValueOperators • sorted
sorted¶
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)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by elements in descending order.
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)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by elements in descending order.
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)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by elements in descending order.
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)
}
}
External resources¶
See also¶
-
ArrayValueOperators.sortedBy
Sort by fields of elements. -
ArrayValueOperators.sortedDescending
Sort by elements in descending order.