We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Problem, Error, Runway

Runway collection sort order bug

After reordering collection items everything is correct, but adding a new item after this will create the correct _order value, but it is not correctly sorted on the output.

Easiest way to show it, is to show that the actual SQL query being ran doesn't show the items correctly sorted.

SQL query on:

perch_collection('Bilkampanjer', array(
                    'filter' => $filters,
                    'sort' => '_order',
                    'sort-order' => 'asc',
SELECT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch3_collection_index idx JOIN perch3_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch3_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch3_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE (idx.collectionID=4) AND ((idx.indexKey='endDate' AND idx.indexValue >= '2018-02-01') OR (idx.indexKey='startDate' AND idx.indexValue <= '2018-02-01') OR (idx.indexKey='visKampanjePaaKampanjeside' AND idx.indexValue='vis')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval HAVING count(*)=3 ORDER BY sortval ASC

See the sorting from sortval See in the picture how it doesnt follow the sortval.

Eddie Dale

Eddie Dale 0 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Which version of Runway are you using?

Duncan Revell

Duncan Revell 78 points
Registered Developer

If you find a sort is ordering by string value (as is happening in your example), you can change the sort type by using

'sort-type' => 'numeric'

Thank you Duncan! That makes total sense, and solved the problem.

It is the v.3.0.8 by the way, Drew.

Drew McLellan

Drew McLellan 2638 points
Perch Support

This was fixed in 3.0.12.

Two ways to solve it then. Even better :-)

Thanks to both for answers.