I am trying to make a call to find, and have the result set ordered.
However, I am experiencing some strange behaviour. The column I want
to sort on is of type varchar, but actually contains floating point
numbers. (I needed to switch the type to varchar to get validation on
the input working properly). So when I just try to order, it returns
in what seems to be a properly ordered (in terms of strings)
collection. However, I am trying to get it to return the collection
sorted in terms of float values. I tried just returning the
collection and then using sort_by with column.to_f, but this wasn't
working (even though when I tried it just through IRB that call to
sort_by on an array of strings worked fine). Here is how the "sorted"
list came out using this method:
So then I tried to implement it in the SQL query, using CAST (ie,
ORDER BY CAST(column as SIGNED) ) but this is returning some strange
results too. For example, here is the "sorted" output of using CAST:
Does anybody have any ideas whats going on, or any other approaches
that I could try to get this working?