0

This piece of code:

->orderBy('weight', 'ASC');

orders the column by the weight ascending. However, the rows are sorted like: 15 - 2 - 20 of course this should be: 2 - 15 - 20

How can I achieve this, specifically for drupal(7)?

1 Answer 1

3

It seems that the database is using lexicographic ordering, while your intention is to use numeric ordering. Numeric ordering is only used when the type of the field is a numeric type. Check whether the field is of a numeric type.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.