diff --git a/include/staff/tasks.inc.php b/include/staff/tasks.inc.php
index 09e9bd3b27f2a1da59171dbd5760a8f87ab720d2..7d2c11b191b4a204e85b5a6f9ab6bf97a5fd83c0 100644
--- a/include/staff/tasks.inc.php
+++ b/include/staff/tasks.inc.php
@@ -14,26 +14,41 @@ unset($args['a']);
 
 $refresh_url = $path . '?' . http_build_query($args);
 
+$sort_options = array(
+    'updated' =>            __('Most Recently Updated'),
+    'created' =>            __('Most Recently Created'),
+    'due' =>                __('Due Soon'),
+    'number' =>             __('Task Number'),
+    'closed' =>             __('Most Recently Closed'),
+    'hot' =>                __('Longest Thread'),
+    'relevance' =>          __('Relevance'),
+);
+
 $queue_name = strtolower($_GET['status'] ?: $_GET['a']); //Status is overloaded
 switch ($queue_name) {
 case 'closed':
     $status='closed';
     $results_type=__('Closed Tasks');
     $showassigned=true; //closed by.
+    $queue_sort_options = array('closed', 'updated', 'created', 'number', 'hot');
+
     break;
 case 'overdue':
     $status='open';
     $results_type=__('Overdue Tasks');
     $tasks->filter(array('isoverdue'=>1));
+    $queue_sort_options = array('updated', 'created', 'number', 'hot');
     break;
 case 'assigned':
     $status='open';
     $staffId=$thisstaff->getId();
     $results_type=__('My Tasks');
     $tasks->filter(array('staff_id'=>$thisstaff->getId()));
+    $queue_sort_options = array('updated', 'created', 'hot', 'number');
     break;
 default:
 case 'search':
+    $queue_sort_options = array('closed', 'updated', 'created', 'number', 'hot');
     // Consider basic search
     if ($_REQUEST['query']) {
         $results_type=__('Search Results');
@@ -55,6 +70,7 @@ case 'search':
 case 'open':
     $status='open';
     $results_type=__('Open Tasks');
+    $queue_sort_options = array('created', 'updated', 'due', 'number', 'hot');
     break;
 }
 
@@ -106,29 +122,39 @@ $tasks->values('id', 'number', 'created', 'staff_id', 'team_id',
         'dept__name', 'cdata__title', 'flags');
 // Apply requested quick filter
 
-// Apply requested sorting
 $queue_sort_key = sprintf(':Q:%s:sort', $queue_name);
 
-if (isset($_GET['sort']))
-    $_SESSION[$queue_sort_key] = $_GET['sort'];
+if (isset($_GET['sort'])) {
+        $_SESSION[$queue_sort_key] = $_GET['sort'];
+}
+elseif (!isset($_SESSION[$queue_sort_key])) {
+        $_SESSION[$queue_sort_key] = $queue_sort_options[0];
+}
+
 switch ($_SESSION[$queue_sort_key]) {
 case 'number':
     $tasks->extra(array(
         'order_by'=>array(SqlExpression::times(new SqlField('number'), 1))
     ));
     break;
-case 'priority,due':
-    $tasks->order_by('cdata__:priority__priority_urgency');
-    // Fall through to add in due date filter
 case 'due':
     $date_header = __('Due Date');
-    $date_col = 'est_duedate';
-    $tasks->values('est_duedate');
-    $tasks->filter(array('est_duedate__isnull'=>false));
-    $tasks->order_by('est_duedate');
+    $date_col = 'duedate';
+    $tasks->values('duedate');
+    $tasks->filter(array('duedate__isnull'=>false));
+    $tasks->order_by('duedate');
     break;
 case 'updated':
-    $tasks->order_by('cdata__:priority__priority_urgency', '-lastupdate');
+    $date_header = __('Last Updated');
+    $date_col = 'updated';
+    $tasks->values('updated');
+    $tasks->order_by('-updated');
+    break;
+case 'hot':
+    $tasks->order_by('-thread_count');
+    $tasks->annotate(array(
+        'thread_count' => SqlAggregate::COUNT('thread__entries'),
+    ));
     break;
 case 'created':
 default:
@@ -178,6 +204,31 @@ if ($thisstaff->hasPerm(Task::PERM_DELETE, false)) {
 ?>
 <!-- SEARCH FORM START -->
 <div id='basic_search'>
+  <div class="pull-right" style="height:25px">
+    <span class="valign-helper"></span>
+    <span class="action-button muted" data-dropdown="#sort-dropdown">
+      <i class="icon-caret-down pull-right"></i>
+      <span><i class="icon-sort-by-attributes-alt"></i> <?php echo __('Sort');?></span>
+    </span>
+    <div id="sort-dropdown" class="action-dropdown anchor-right"
+    onclick="javascript: $.pjax({
+        url:'?' + addSearchParam('sort', $(event.target).data('mode')),
+        timeout: 2000,
+        container: '#pjax-container'});">
+      <ul class="bleed-left">
+        <?php foreach ($queue_sort_options as $mode) {
+        $desc = $sort_options[$mode];
+        $selected = $mode == $_SESSION[$queue_sort_key]; ?>
+      <li <?php if ($selected) echo 'class="active"'; ?>>
+        <a href="#" data-mode="<?php echo $mode; ?>"><i class="icon-fixed-width <?php
+          if ($selected) echo 'icon-hand-right';
+          ?>"></i> <?php echo Format::htmlchars($desc); ?></a>
+      </li>
+<?php } ?>
+      </ul>
+    </div>
+  </div>
+
     <form action="tasks.php" method="get">
     <input type="hidden" name="a" value="search">
     <table>
@@ -204,20 +255,6 @@ if ($thisstaff->hasPerm(Task::PERM_DELETE, false)) {
                 $results_type.$showing; ?></a></h2>
         </div>
         <div class="pull-right flush-right">
-            <span style="display:inline-block">
-                <span style="vertical-align: baseline">Sort:</span>
-            <select name="sort" onchange="javascript:addSearchParam('sort', $(this).val());">
-<?php foreach (array(
-    'created' =>    __('Most Recently Created'),
-    'updated' =>    __('Most Recently Updated'),
-    'due' =>        __('Due Soon'),
-    'priority,due' => __('Priority + Due Soon'),
-    'number' =>     __('Task Number'),
-) as $mode => $desc) { ?>
-            <option value="<?php echo $mode; ?>" <?php if ($mode == $_SESSION[$queue_sort_key]) echo 'selected="selected"'; ?>><?php echo $desc; ?></option>
-<?php } ?>
-            </select>
-            </span>
            <?php
             Task::getAgentActions($thisstaff, array('status' => $status));
             ?>
diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php
index 8d6c2bc4a8135ba38bb56ed85bbbe0b844971481..d076ade82a078c0272e5c42a9209f6166bb02216 100644
--- a/include/staff/tickets.inc.php
+++ b/include/staff/tickets.inc.php
@@ -316,7 +316,7 @@ $_SESSION[':Q:tickets'] = $orig_tickets;
       <span><i class="icon-sort-by-attributes-alt"></i> <?php echo __('Sort');?></span>
     </span>
     <div id="sort-dropdown" class="action-dropdown anchor-right"
-    onclick="javascript: console.log(event); $.pjax({
+    onclick="javascript: $.pjax({
         url:'?' + addSearchParam('sort', $(event.target).data('mode')),
         timeout: 2000,
         container: '#pjax-container'});">
@@ -325,7 +325,7 @@ $_SESSION[':Q:tickets'] = $orig_tickets;
 $desc = $sort_options[$mode];
 $selected = $mode == $_SESSION[$queue_sort_key]; ?>
       <li <?php if ($selected) echo 'class="active"'; ?>>
-        <a data-mode="<?php echo $mode; ?>"><i class="icon-fixed-width <?php
+        <a href="#" data-mode="<?php echo $mode; ?>"><i class="icon-fixed-width <?php
           if ($selected) echo 'icon-hand-right';
           ?>"></i> <?php echo Format::htmlchars($desc); ?></a>
       </li>