Body: <p>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?</p>
  
  <p>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:</p>
  
  <p><a href="https://civicrm.stackexchange.com/questions/2209/how-to-provide-a-default-sort-on-a-custom-search">How to provide a default sort on a custom search?</a></p>
  
  <p>Any way to set a default sort column with the newer version of the code?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-18T20:21:08.003Z
Comments.Text: You could always use the data processor extension which allows you to build custom searches with a sort
Comments.UserDisplayName: Andy Clark
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-19T00:13:12.673Z
Comments.Text: @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.
Comments.UserDisplayName: Paul B
Tags: <custom-search>
Title: Default sort field for a Custom Search?
ThreadText: # Default sort field for a Custom Search?
  
  (Asked by: username_0 on 2020-05-18)
  
  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?](https://civicrm.stackexchange.com/questions/2209/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?
  
  **Tags:** custom-search
  
  > **Comments:**
  > **username_1**: You could always use the data processor extension which allows you to build custom searches with a sort  
  > **username_0**: @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.  
  
  ---
  
  ## 0 answers
  
  