/**
 * Given a list of photos, this function calculates the top photos based on their rating score,
 * and returns the list of top photos sorted in descending order.
 *
 * @param photos A list of maps representing the photos, each containing the keys 'photo_id' and 'rating'.
 * @return A list of maps representing the top photos, sorted in descending order based on rating score.
 *
 * Note:
 * - The rating is represented by an integer value; higher values indicate better photos.
 * - The 'photo_id' is a unique identifier for each photo.
 */
fun calculateTopPhotos(photos: List<Map<String, Any>>): List<Map<String, Any>> {

    val topPhotos = mutableListOf<Map<String, Any>>()
    var highestRating = 0

    for (photo in photos) {
        if (photo["rating"] as Int > highestRating) {
            highestRating = photo["rating"] as Int
        }
    }

    for (photo in photos) {
        if (photo["rating"] as Int == highestRating) {
            topPhotos.add(photo)
        }
    }

    return topPhotos.sortedByDescending { it["rating"] as Int }
}
/**
 * Given a list of photos, this function calculates the top photos based on their rating score,
 * and returns the list of top photos sorted in descending order.
 *
 * @param photos A list of maps representing the photos, each containing the keys 'photo_id' and 'rating'.
 * @return A list of maps representing the top photos, sorted in descending order based on rating score.
 *
 * Note:
 * - The rating is represented by an integer value; higher values indicate better photos.
 * - The 'photo_id' is a unique identifier for each photo.
 */
fun calculateTopPhotos(photos: List<Map<String, Any>>): List<Map<String, Any>> {
/**
 * Given a list of photos, this function calculates the top photos based on their rating score,
 * and returns the list of top photos sorted in descending order.
 *
 * @param photos A list of maps representing the photos, each containing the keys 'photo_id' and 'rating'.
 * @return A list of maps representing the top photos, sorted in descending order based on rating score.
 *
 * Note:
 * - The rating is represented by an integer value; higher values indicate better photos.
 * - The 'photo_id' is a unique identifier for each photo.
 */
fun calculateTopPhotos(photos: List<Map<String, Any>>): List<Map<String, Any>> {

    val topPhotos = mutableListOf<Map<String, Any>>()
    var highestRating = 0

    for (photo in photos) {
        if (photo["rating"] as Int > highestRating) {
            highestRating = photo["rating"] as Int
        }
    }

    for (photo in photos) {
        if (photo["rating"] as Int == highestRating) {
            topPhotos.add(photo)
        }
    }

    return topPhotos.sortedByDescending { it["rating"] as Int }
}