From 31fd348dc649826d5700702802fb2b60775dc1e1 Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Mon, 10 Oct 2016 18:43:33 -0500 Subject: [PATCH] CRM-16838: Sort task contacts again after merging households. --- CRM/Contact/Form/Task.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CRM/Contact/Form/Task.php b/CRM/Contact/Form/Task.php index e3b94b6b2d..e0fd60b505 100644 --- a/CRM/Contact/Form/Task.php +++ b/CRM/Contact/Form/Task.php @@ -443,6 +443,21 @@ class CRM_Contact_Form_Task extends CRM_Core_Form { } $householdsDAO->free(); } + + // If contact list has changed, households will probably be at the end of + // the list. Sort it again by sort_name. + if (implode(',', $this->_contactIds) != $relID) { + $contact_sort = array(); + $result = civicrm_api3('Contact', 'get', array( + 'return' => array('id'), + 'id' => array('IN' => $this->_contactIds), + 'options' => array( + 'limit' => 0, + 'sort' => "sort_name" + ), + )); + $this->_contactIds = array_keys($result['values']); + } } /** -- 2.25.1