/**
 * As an anthropologist, your task is to find the common characters in two given strings.
 *
 * You need to write a Kotlin function called findCommonCharacter that takes in two strings as arguments,
 * and returns a string containing the common characters found in both strings, in alphabetical order.
 *
 * Example:
 * findCommonCharacter("hello", "world") -> "lo"
 *
 * Note:
 * - The function should be case-sensitive, meaning that 'a' and 'A' are considered different characters.
 * - The order of characters in the returned string should be in alphabetical order.
 * - You can assume that the input strings only contain alphabetical characters.
 */
fun findCommonCharacter(string1: String, string2: String): String {

    var commonCharacters = ""

    for (char1 in string1) {
        if (char1 in string2 && char1 !in commonCharacters) {
            commonCharacters += char1
        }
    }

    return commonCharacters.toCharArray().sorted().joinToString(separator = "") // Sorts the characters in alphabetical order
}
/**
 * As an anthropologist, your task is to find the common characters in two given strings.
 *
 * You need to write a Kotlin function called findCommonCharacter that takes in two strings as arguments,
 * and returns a string containing the common characters found in both strings, in alphabetical order.
 *
 * Example:
 * findCommonCharacter("hello", "world") -> "lo"
 *
 * Note:
 * - The function should be case-sensitive, meaning that 'a' and 'A' are considered different characters.
 * - The order of characters in the returned string should be in alphabetical order.
 * - You can assume that the input strings only contain alphabetical characters.
 */
fun findCommonCharacter(string1: String, string2: String): String {
/**
 * As an anthropologist, your task is to find the common characters in two given strings.
 *
 * You need to write a Kotlin function called findCommonCharacter that takes in two strings as arguments,
 * and returns a string containing the common characters found in both strings, in alphabetical order.
 *
 * Example:
 * findCommonCharacter("hello", "world") -> "lo"
 *
 * Note:
 * - The function should be case-sensitive, meaning that 'a' and 'A' are considered different characters.
 * - The order of characters in the returned string should be in alphabetical order.
 * - You can assume that the input strings only contain alphabetical characters.
 */
fun findCommonCharacter(string1: String, string2: String): String {

    var commonCharacters = ""

    for (char1 in string1) {
        if (char1 in string2 && char1 !in commonCharacters) {
            commonCharacters += char1
        }
    }

    return commonCharacters.toCharArray().sorted().joinToString(separator = "") // Sorts the characters in alphabetical order
}