I am trying to sort a set of object s, where s class has an instance method called some_method
defined in Model of S that returns a value v.
def some_method(id)
...
return something # a float number
end
Class S is related to class C with many_to_many relation. (class C has_many s and class S has_many c). I get this set of s objects by calling C.find(c_id).s
I am trying something like this
C.find(c_id).s.sort{|a,b| a.some_method(id) <=> b.some_method(id)}
but I fail to sort the array. How am I supposed to do this?