Merge pull request #2626 from vlakoff/develop-2

Code cleanup in db->order_by()