Method: Mongo::Cursor#sort
- Defined in:
- lib/mongo/cursor.rb
#sort(key_or_list, direction = nil) ⇒ Object
Sort this cursor’s results.
This method overrides any sort order specified in the Collection#find method, and only the last sort applied has an effect.
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/mongo/cursor.rb', line 147 def sort(key_or_list, direction=nil) check_modifiable if !direction.nil? order = [[key_or_list, direction]] else order = key_or_list end @order = order self end |