CRM-13996, fixes sorting for search views

----------------------------------------
* CRM-13996: Advanced Search; Sorting of Results displayed in a custom profile fails and Advanced Search must be reset
  http://issues.civicrm.org/jira/browse/CRM-13996
Merge pull request #2351 from kurund/CRM-13996

CRM-13996, fixes sorting for search views
CRM-13889 - CRM_Core_BAO_Dashboard - Fix test failure. Report error better.

Note: It looks like there was a merge error because some of the relevant
code was badly duplicated.
CRM-13889 - Autoformat
Merge pull request #2354 from totten/4.4-dashboard-api

CRM-13889 - CRM_Core_BAO_Dashboard - Fix test failure.
Merge pull request #2352 from colemanw/4.4

Fix search builder participant/member options
CRM-14028 - Workaround the number 0 == empty() php bug