Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.aggregation.operatorsArrayValueOperatorssortedDescending

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

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

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

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