Answers.Body: <p>The answer is already here. According to tiny mention at the bottom of <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Directories" rel="nofollow">http://wiki.civicrm.org/confluence/display/CRMDOC/Directories</a> page, it is possible (and, more important, it works!) to copy modofyed core files to  <strong>Custom PHP Path Directory</strong> (at civicrm/admin/setting/path?reset=1) , preserving original files/folders structure, so next time CiviCRM gets security updates, changes should be kept (unless original file / function major changes). </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-27T10:25:58.617Z
Answers.LastActivityDate: 2015-11-27T10:25:58.617Z
Answers.UserDisplayName: yurg
Body: <p>Looks like one of core CiviCRM files (namely part of mySQL query at CRM/Contact/BAO/Query.php) has to be changed in order to achieve "<a href="https://civicrm.stackexchange.com/questions/7720/search-result-sort-by-last-name">Search results sort by Last Name</a>". What would be the best (I mean, most proper) way in CiviCRM to do this?</p>
  
Tags: <api><extension><hooks><developer><mysql>
Title: How do I modify a core CiviCRM file (to change a search order)?
ThreadText: # How do I modify a core CiviCRM file (to change a search order)?
  
  (Asked by: username_0 on 2015-11-19)
  
  Looks like one of core CiviCRM files (namely part of mySQL query at CRM/Contact/BAO/Query.php) has to be changed in order to achieve "[Search results sort by Last Name](https://civicrm.stackexchange.com/questions/7720/search-result-sort-by-last-name)". What would be the best (I mean, most proper) way in CiviCRM to do this?
  
  **Tags:** api, extension, hooks, developer, mysql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-11-27. Score: 1 | Accepted answer
  
  The answer is already here. According to tiny mention at the bottom of <http://wiki.civicrm.org/confluence/display/CRMDOC/Directories> page, it is possible (and, more important, it works!) to copy modofyed core files to **Custom PHP Path Directory** (at civicrm/admin/setting/path?reset=1) , preserving original files/folders structure, so next time CiviCRM gets security updates, changes should be kept (unless original file / function major changes).
  
  
  ---
  
  