/**
 * This function takes a dictionary 'library' of books as input and a string 'book' as the desired book to search.
 * It modifies the 'library' to remove all books with a higher alphabetical order than the desired book.
 * The function also has a feature to break out of the loop as soon as it finds the desired book.
 *
 * @param library A dictionary containing books as keys and their corresponding information.
 * @param book The desired book to search in the library.
 * @return The modified 'library' dictionary.
 */
fun librarianBooks(library: MutableMap<String, String>, book: String): MutableMap<String, String> {

    val keysToRemove = mutableListOf<String>()
    var foundBook = false

    for (key in library.keys.toList()) {
        if (key > book) {
            keysToRemove.add(key)
        } else if (key == book) {
            foundBook = true
            break
        }
    }

    keysToRemove.forEach { library.remove(it) }

    return library
}
/**
 * This function takes a dictionary 'library' of books as input and a string 'book' as the desired book to search.
 * It modifies the 'library' to remove all books with a higher alphabetical order than the desired book.
 * The function also has a feature to break out of the loop as soon as it finds the desired book.
 *
 * @param library A dictionary containing books as keys and their corresponding information.
 * @param book The desired book to search in the library.
 * @return The modified 'library' dictionary.
 */
fun librarianBooks(library: MutableMap<String, String>, book: String): MutableMap<String, String> {
/**
 * This function takes a dictionary 'library' of books as input and a string 'book' as the desired book to search.
 * It modifies the 'library' to remove all books with a higher alphabetical order than the desired book.
 * The function also has a feature to break out of the loop as soon as it finds the desired book.
 *
 * @param library A dictionary containing books as keys and their corresponding information.
 * @param book The desired book to search in the library.
 * @return The modified 'library' dictionary.
 */
fun librarianBooks(library: MutableMap<String, String>, book: String): MutableMap<String, String> {

    val keysToRemove = mutableListOf<String>()
    var foundBook = false

    for (key in library.keys.toList()) {
        if (key > book) {
            keysToRemove.add(key)
        } else if (key == book) {
            foundBook = true
            break
        }
    }

    keysToRemove.forEach { library.remove(it) }

    return library
}