Hello I'd like to sort an array in a Rails Controller. I want to sort the array before I loop over it in the View
@projects = Project.all.sort #throws error
#and
@projects = Project.all
@projects.sort # throws error
throws this error: undefined method <=>
for #<Project:0x101f70b28>
but when I query:
@projects.respond_to?('sort')
I get true
How can I sort the array? Should it be done in the View or in the Controller? Any help is highly appreciated!