can't sort search result table by column when the column shows a custom field
For 5.15.1 you can add these lines just before line 6373 in CRM/Contact/BAO/Query.php.

if (empty($fieldSpec['bao'])) {
  continue;
}


There will also be a similar workaround put into 5.18.2 when it is released. https://github.com/civicrm/civicrm-core/pull/15454