Sorting Quentin's movies

Report a typo

Quentin wants to create a Go program that takes as input 3 of his movies and then sorts them based on the highest rating first, and then by the movie name in descending order (from z to a)!

Please help Quentin implement the appropriate sorting operation in his program.

This problem uses the bufio and os packages to read a whitespace-separated string from the input. To solve this task, you don't need to know how the bufio/os packages work. The only objective is to sort the movies slice and print the properly sorted movies slice within the fmt.Println() statement.

Sample Input 1:

Pulp Fiction
91
Django Unchained
86
Reservoir Dogs
91

Sample Output 1:

[{Reservoir Dogs 91} {Pulp Fiction 91} {Django Unchained 86}]
Write a program in Go
package main

import (
"bufio"
"fmt"
"os"
"sort"
)

type Movie struct {
Name string
Rating int
}

func main() {
movies := readMovies()

// Implement the sorting logic within the sort.Slice function below!
sort.Slice(movies, func(i, j int) bool {
if movies[i].Rating ? movies[j].Rating {
return movies[i].? > movies[j].?
}
return movies[i].Name ? movies[j].Name
})

// The print statement below outputs the sorted slice, do not delete it!
fmt.Println(movies)
}

// readMovies is a helper to read the movies for this task
// DO NOT EDIT
func readMovies() []Movie {
var (
name string
rating int
movies []Movie
___

Create a free account to access the full topic