module API
  module V1
    module Entities
      class Ranking < Grape::Entity
        expose :player, using: Entities::Player
        expose :rating
      end
    end

    class Rankings < Grape::API
      resource :rankings do
        desc "Returns an ordered list of player rankings"
        get do
          rankings = Player.all.map { |player|
            {
              player: player,
              rating: player.rating
            }
          }.sort_by { |ranking| ranking[:rating] }.reverse
          present rankings, with: Entities::Ranking
        end
      end
    end
  end
end

module API
  module V1
    module Entities
      class Ranking < Grape::Entity
        expose :player, using: Entities::Player
        expose :rating
      end
    end

    class Rankings < Grape::API
      resource :rankings do
        desc "Returns an list of player rankings in descending rating order"
        get do
          rankings = Player.all.map { |player|
            {
              player: player,
              rating: player.rating
            }
          }.sort_by { |ranking| ranking[:rating] }.reverse
          present rankings, with: Entities::Ranking
        end
      end
    end
  end
end

Clarify player ranking order in endpoint description
Clarify player ranking order in endpoint description
