Order_by错误1 10 11 12

I am with a php code that is giving error in the Order_by this appearing the links in wrong orders was to appear 1 2 3 4 5. and it is appearing 1 10 11 12

Can someone help me solve this?

$this->db->order_by('source_type', "DESC");

I think that although it is a strange problem it is very useful for many people who need to solve this problem .. I did not find anything on the internet that could help me with this

It would appear that your source_type field is declared as VARCHAR. If you try

SELECT '2' > '10'

You will get a result of 1 (true). So to make the values sort properly, you need to convert them to integers i.e.

ORDER BY CAST(source_type AS UNSIGNED) DESC

Without knowing your framework it's hard to know exactly how to specify that in the order_by method.