I'm building a custom search and I would like it to have a default sort on (order by) a specific field other than the first field in the list. How can I provide a default sort field?

This stackexchange answer's method doesn't seem to be valid anymore, as it seems the $sort variable is now a non-empty object on initial load of my custom search:

How to provide a default sort on a custom search?

Any way to set a default sort column with the newer version of the code?

  • You could always use the data processor extension which allows you to build custom searches with a sort – Andy Clark May 18 '20 at 20:21
  • @AndyClark, unfortunately, I tried that extension (still have it installed) and it has several bugs that are bigger issues than sorting for my use case (I've put a few bug reports to help out the developer with some). A big one is joining to another table via a custom field value, it completely breaks the underlying SQL. Otherwise, I love that extension and would use it once it's more mature. Until then, I just need something I can throw complex SQL at and allow a default sort field. – Paul B May 19 '20 at 0:13

Your Answer

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

Browse other questions tagged or ask your own question.