/**
 * Given a list of photos, this function finds the common tags between them and returns a sorted list of these tags.
 */
fun findCommonTags(photos: List<Map<String, List<String>>>): List<String> {

    val commonTags = mutableListOf<String>()

    // Iterate over each photo
    for (photo in photos) {
        val tags = photo["tags"] ?: emptyList()

        // Iterate over each tag in the current photo
        for (tag in tags) {
            var isCommon = true

            // Check if the tag is present in all photos
            for (otherPhoto in photos) {
                if (tag !in otherPhoto["tags"] ?: emptyList()) {
                    isCommon = false
                    break
                }
            }

            // If the tag is common, add it to the list
            if (isCommon && tag !in commonTags) {
                commonTags.add(tag)
            }
        }
    }

    // Sort the common tags and return them
    return commonTags.sorted()
}
/**
 * Given a list of photos, this function finds the common tags between them and returns a sorted list of these tags.
 */
fun findCommonTags(photos: List<Map<String, List<String>>>): List<String> {
/**
 * Given a list of photos, this function finds the common tags between them and returns a sorted list of these tags.
 */
fun findCommonTags(photos: List<Map<String, List<String>>>): List<String> {

    val commonTags = mutableListOf<String>()

    // Iterate over each photo
    for (photo in photos) {
        val tags = photo["tags"] ?: emptyList()

        // Iterate over each tag in the current photo
        for (tag in tags) {
            var isCommon = true

            // Check if the tag is present in all photos
            for (otherPhoto in photos) {
                if (tag !in otherPhoto["tags"] ?: emptyList()) {
                    isCommon = false
                    break
                }
            }

            // If the tag is common, add it to the list
            if (isCommon && tag !in commonTags) {
                commonTags.add(tag)
            }
        }
    }

    // Sort the common tags and return them
    return commonTags.sorted()
}