I have a custom grid, I am trying to sort it in desc order What I did

Try 1:- In my Grid Collection:

protected function _renderFiltersBefore()
        $orderUpdate = $this->getTable('xyztable');
        $this->getSelect()->order('main_table.order_id', 'desc');

Try 2:- In uicomponent file:

<column name="order_id">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="sorting" xsi:type="string">desc</item>
                    <item name="filter" xsi:type="string">textRange</item>
                    <item name="label" xsi:type="string" translate="true">Order ID</item>


Output: It sort like: 1, 10, 12, 2, 3, 4, 41, 42, 5

Expected Result: 42, 41, 12, 10, 5, 4, 3, 2, 1

I had spend couple of hours in this but didn't find any solution. Please help me to solve this issue.

1 Answer 1


Well, After speding couple of hours I checked the column order_id is varchar type because of which sorting result was not accurate. I make it int(10) and issue solved.


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.