All academies
All challenges

Genre power ranking

hard+85 XP

In cinema.movies, unwind genres and compute the average rating per genre, rounded to 2 decimals as avgRating, sorted by avgRating descending. Output: { _id: genre, avgRating: n }.

Sample of cinema.movies

{
  _id: 1,
  title: "Inception",
  year: 2010,
  genres: [
    "sci-fi",
    "thriller"
  ],
  rating: 8.8,
  director: "Christopher Nolan",
  boxOffice: 836.8
}
{
  _id: 2,
  title: "Interstellar",
  year: 2014,
  genres: [
    "sci-fi",
    "drama"
  ],
  rating: 8.7,
  director: "Christopher Nolan",
  boxOffice: 701.7
}
{
  _id: 3,
  title: "Parasite",
  year: 2019,
  genres: [
    "thriller",
    "drama"
  ],
  rating: 8.5,
  director: "Bong Joon-ho",
  boxOffice: 258.8
}