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)?


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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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