Answers.Body: <p>I don't think you can do it in the smarty template but since you might want the sorting of similar listings to be consistent anywhere it's used you could just change line 545 in CRM_Case_BAO_Case::getCaseActivityQuery() so that it sorts descending.</p>
  
  <pre><code>      $query .= " ORDER BY case_recent_activity_date ASC ";
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>      $query .= " ORDER BY case_recent_activity_date DESC ";
  </code></pre>
  
  <p>Obviously editing core files directly isn't recommended, but that's where the sorting happens for this.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-12T09:33:08.783Z
Answers.Text: thanks! i'll do some careful checking before making any core changes.. perhaps i can do it with a module/extension though.
Answers.UserDisplayName: user3016811
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-12T18:11:39.247Z
Answers.Text: You might be able to do it with the pageRun hook, and then re-sort the "recentCases" element. Haven't tested but something like $recentCases = $page->get_template_vars('recentCases'); which should give you an array you can sort. https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_pageRun
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-12T04:44:14.773Z
Answers.LastActivityDate: 2017-12-12T04:44:14.773Z
Answers.UserDisplayName: Demerit
Body: <p>Currently cases with recent activities are sorted oldest>newest - i'd like the newest to be at the top.</p>
  
  <p>I am guessing i could do it within Case/Page/DashboardSelector.tpl but i'm floundering from there.. is it possible? thanks!</p>
  
Tags: <civicase><sort-order>
Title: Changing sort of cases with recent activities on case dashboard?
ThreadText: # Changing sort of cases with recent activities on case dashboard?
  
  (Asked by: username_0 on 2017-12-11)
  
  Currently cases with recent activities are sorted oldest>newest - i'd like the newest to be at the top.
  
  I am guessing i could do it within Case/Page/DashboardSelector.tpl but i'm floundering from there.. is it possible? thanks!
  
  **Tags:** civicase, sort-order
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-12-12. Score: 3 | Accepted answer
  
  I don't think you can do it in the smarty template but since you might want the sorting of similar listings to be consistent anywhere it's used you could just change line 545 in CRM_Case_BAO_Case::getCaseActivityQuery() so that it sorts descending.
        $query .= " ORDER BY case_recent_activity_date ASC ";
  
  becomes
        $query .= " ORDER BY case_recent_activity_date DESC ";
  
  Obviously editing core files directly isn't recommended, but that's where the sorting happens for this.
  
  > **Comments:**
  > **username_0**: thanks! i'll do some careful checking before making any core changes.. perhaps i can do it with a module/extension though.  
  > **username_1**: You might be able to do it with the pageRun hook, and then re-sort the "recentCases" element. Haven't tested but something like $recentCases = $page->get_template_vars('recentCases'); which should give you an array you can sort. https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_pageRun  
  
  ---
  
  