```ruby
class API::V1::CountriesController < API::APIController

  def index
    @countries = Portal::Country.all.map{ |c| {name: c.name, id: c.id} }
    render :json => @countries
  end

end
```

Sort countries by name before output in API
user
```ruby
class API::V1::CountriesController < API::APIController

  def index
    @countries = Portal::Country.all.sort_by{ |k| k["name"]}.map{ |c| {name: c.name, id: c.id} }
    render :json => @countries
  end

end
```
assistant