Sha256: 11fb3dacf41d6d28a647038cea08125b0790c9ca9e7d6608bcd756dc1881a004

Contents?: true

Size: 285 Bytes

Versions: 4

Compression:

Stored size: 285 Bytes

Contents

class HomeController < ApplicationController
  sort_with :desc do |scope|
    scope.sort {|a,b| a.v > b.v}
  end

  def index
    @collection = apply_sort(collection)
    render json: @collection
  end

  private
  def collection
    @collection ||= [{v: 1}, {v: 2}, {v: 3}]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
collection_sorter-0.0.4 test/dummy/app/controllers/home_controller.rb
collection_sorter-0.0.3 test/dummy/app/controllers/home_controller.rb
collection_sorter-0.0.2 test/dummy/app/controllers/home_controller.rb
collection_sorter-0.0.1 test/dummy/app/controllers/home_controller.rb