/**
 * You are a librarian tasked with sorting a collection of books based on their popularity.
 * Each book is represented as a Pair with the format (title, popularity).
 * Your task is to sort the books in descending order of popularity and shift them by a specified value.
 * Return the sorted and shifted books as a List.
 *
 * @param books A List containing the collection of books. Each book is represented as a Pair with the format (title, popularity).
 * @param shift The value by which the sorted books should be shifted.
 * @return The sorted and shifted books as a List.
 *
 * Example:
 * librarySortBooks(listOf("Book1" to 8, "Book2" to 5, "Book3" to 10), 2)
 * Output: listOf("Book3" to 10, "Book1" to 8, "Book2" to 5)
 */
fun librarySortBooks(books: List<Pair<String, Int>>, shift: Int): List<Pair<String, Int>> {

    val sortedBooks = books.sortedByDescending { it.second }
    val shiftedBooks = sortedBooks.subList(shift, sortedBooks.size) + sortedBooks.subList(0, shift)
    return shiftedBooks
}
/**
 * You are a librarian tasked with sorting a collection of books based on their popularity.
 * Each book is represented as a Pair with the format (title, popularity).
 * Your task is to sort the books in descending order of popularity and shift them by a specified value.
 * Return the sorted and shifted books as a List.
 *
 * @param books A List containing the collection of books. Each book is represented as a Pair with the format (title, popularity).
 * @param shift The value by which the sorted books should be shifted.
 * @return The sorted and shifted books as a List.
 *
 * Example:
 * librarySortBooks(listOf("Book1" to 8, "Book2" to 5, "Book3" to 10), 2)
 * Output: listOf("Book3" to 10, "Book1" to 8, "Book2" to 5)
 */
fun librarySortBooks(books: List<Pair<String, Int>>, shift: Int): List<Pair<String, Int>> {
/**
 * You are a librarian tasked with sorting a collection of books based on their popularity.
 * Each book is represented as a Pair with the format (title, popularity).
 * Your task is to sort the books in descending order of popularity and shift them by a specified value.
 * Return the sorted and shifted books as a List.
 *
 * @param books A List containing the collection of books. Each book is represented as a Pair with the format (title, popularity).
 * @param shift The value by which the sorted books should be shifted.
 * @return The sorted and shifted books as a List.
 *
 * Example:
 * librarySortBooks(listOf("Book1" to 8, "Book2" to 5, "Book3" to 10), 2)
 * Output: listOf("Book3" to 10, "Book1" to 8, "Book2" to 5)
 */
fun librarySortBooks(books: List<Pair<String, Int>>, shift: Int): List<Pair<String, Int>> {

    val sortedBooks = books.sortedByDescending { it.second }
    val shiftedBooks = sortedBooks.subList(shift, sortedBooks.size) + sortedBooks.subList(0, shift)
    return shiftedBooks
}