E
E
eldar_web2015-10-06 17:39:11
Ruby on Rails
eldar_web, 2015-10-06 17:39:11

Why in Ruby on Rails, when sorting, are numbers below 10 greater than those above 10?

For example, there are records in the database (MySQL), fields (num) with values ​​7, 31, 54.
So if I sort like this: Table.order('num DESC'), then this option will appear:
7
54
31
And vice versa (without DESC).
And if instead of 7 there will be 10 (and higher), then it will be in the normal order.
Why such a problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EvgeniyKonstantinov, 2015-10-06
@eldar_web

Because the num field seems to be character/text, and not one of the numeric types.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question