MongoDB request DSL • opensavvy.ktmongo.dsl.aggregation.operators • ArrayValueOperators • sortedBy
sortedBy¶
Sorts an array based on fields of its elements.
Example¶
class Score(
val value: Int,
)
class Player(
val _id: ObjectId,
val scores: List<Score>,
val bestScores: List<Score>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedBy { ascending(Score::value) }
}
}
External resources¶
See also¶
-
ArrayValueOperators.sorted
Sort by the elements themselves (ascending order). -
ArrayValueOperators.sortedDescending
Sort by the elements themselves (descending order).
Sorts an array based on fields of its elements.
Example¶
class Score(
val value: Int,
)
class Player(
val _id: ObjectId,
val scores: List<Score>,
val bestScores: List<Score>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedBy { ascending(Score::value) }
}
}
External resources¶
See also¶
-
ArrayValueOperators.sorted
Sort by the elements themselves (ascending order). -
ArrayValueOperators.sortedDescending
Sort by the elements themselves (descending order).
Sorts an array based on fields of its elements.
Example¶
class Score(
val value: Int,
)
class Player(
val _id: ObjectId,
val scores: List<Score>,
val bestScores: List<Score>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedBy { ascending(Score::value) }
}
}
External resources¶
See also¶
-
ArrayValueOperators.sorted
Sort by the elements themselves (ascending order). -
ArrayValueOperators.sortedDescending
Sort by the elements themselves (descending order).
Sorts an array based on fields of its elements.
Example¶
class Score(
val value: Int,
)
class Player(
val _id: ObjectId,
val scores: List<Score>,
val bestScores: List<Score>,
)
players.updateManyWithPipeline {
set {
Player::bestScores set Player::scores
.sortedBy { ascending(Score::value) }
}
}
External resources¶
See also¶
-
ArrayValueOperators.sorted
Sort by the elements themselves (ascending order). -
ArrayValueOperators.sortedDescending
Sort by the elements themselves (descending order).