concept vote in category scala

appears as: vote
Get Programming with Scala

This is an excerpt from Manning's book Get Programming with Scala.

  • Find the top five productions per vote average and count with at least 50 votes
  • Listing 33.8: Top 5 movies per vote average and count
    printResult(
        question = "TOP 5 movies per vote average and count",
        answers = {
          val topPerVote = movies.filter(_.voteCount >= 50).sortBy(movie =>
            (- movie.voteAverage, - movie.voteCount)
          ).take(5)
          topPerVote.map { movie =>
            s"[AVG: ${movie.voteAverage}, COUNT: ${movie.voteCount}] 
      ${movie.title}" }
        }
      )