+
+ // get the current sort order
+ $currentSortID = CRM_Utils_Request::retrieve('crmSID', 'String', CRM_Core_DAO::$_nullObject);
+
+ $session = CRM_Core_Session::singleton();
+
+ // get previous sort id
+ $previousSortID = $session->get('previousSortID');
+
+ // check for current != previous to ensure cache is not reset if paging is done without changing
+ // sort criteria
+ if (!$pageNum || (!empty($currentSortID) && $currentSortID != $previousSortID) ) {