diff --git a/include/class.config.php b/include/class.config.php
index 8f10d777aa31df72875c9704d359c9a85416f9c2..bab8ecb7b85f7b4ffeaab1f0b59940ccec0b9033 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -1244,6 +1244,16 @@ class OsticketConfig extends Config {
         if(!Validator::process($f, $vars, $errors) || $errors)
             return false;
 
+        // Sort ticket queues
+        require_once INCLUDE_DIR . 'class.queue.php';
+        $queues = CustomQueue::objects()->all();
+        foreach ($vars['qsort'] as $queue_id => $sort) {
+            if ($q = $queues->findFirst(array('id' => $queue_id))) {
+                $q->sort = $sort;
+                $q->save();
+            }
+        }
+
         return $this->updateAll(array(
             'ticket_number_format'=>$vars['ticket_number_format'] ?: '######',
             'ticket_sequence_id'=>$vars['ticket_sequence_id'] ?: 0,
diff --git a/include/class.orm.php b/include/class.orm.php
index a5b335dc6be42b0b53217a7d8739a34a81c2bf59..8b0fdedefb756fce7c49c00319813c5234d5b7b3 100644
--- a/include/class.orm.php
+++ b/include/class.orm.php
@@ -1882,7 +1882,7 @@ implements Iterator {
      * database.
      */
     function findAll(array $criteria, $limit=false) {
-        $records = array();
+        $records = new ListObject();
         foreach ($this as $record) {
             $matches = true;
             foreach ($criteria as $field => $check) {
diff --git a/include/class.queue.php b/include/class.queue.php
index 7f3facb5d7ff8f401faef04de8e1aafa193ab37c..05f0c75eaa173c471e29fdcffcccd93636d595af 100644
--- a/include/class.queue.php
+++ b/include/class.queue.php
@@ -19,7 +19,6 @@ require_once INCLUDE_DIR . 'class.search.php';
 class CustomQueue extends SavedSearch {
     static $meta = array(
         'select_related' => array('parent'),
-        'ordering' => array('title', 'path'),
         'joins' => array(
             'columns' => array(
                 'reverse' => 'QueueColumn.queue',
diff --git a/include/staff/queue.inc.php b/include/staff/queue.inc.php
index 3cc19582d28ab3ae2d7e9a9337fa6faea4c08af6..9a23e1f3ed81f1bd6c19b04d1f56c062a6a2a926 100644
--- a/include/staff/queue.inc.php
+++ b/include/staff/queue.inc.php
@@ -29,7 +29,8 @@ else {
   <input type="hidden" name="id" value="<?php echo $info['id']; ?>">
   <input type="hidden" name="root" value="<?php echo Format::htmlchars($_REQUEST['t']); ?>">
 
-  <h2><?php echo __('Ticket Queues'); ?> // <?php echo $title; ?>
+  <h2><a href="settings.php?t=tickets#queues"><?php echo __('Ticket Queues'); ?></a>
+      // <?php echo $title; ?>
       <?php if (isset($queue->id)) { ?><small>
       — <?php echo $queue->getName(); ?></small>
       <?php } ?>
diff --git a/include/staff/queues-ticket.inc.php b/include/staff/queues-ticket.inc.php
index c4b43397a1c8c39f831e60a1443b78981d6a6977..dfbfbf8b5360cef73786e3041fc759d5c3b175df 100644
--- a/include/staff/queues-ticket.inc.php
+++ b/include/staff/queues-ticket.inc.php
@@ -1,7 +1,6 @@
 <?php
 require_once INCLUDE_DIR . 'class.queue.php';
 ?>
-<form action="queues.php?t=tickets" method="POST" name="keys">
     <div>
         <div class="pull-right">
             <a href="queues.php?t=tickets&amp;a=add" class="green button action-button"><i class="icon-plus-sign"></i> <?php echo __('Add New Queue');?></a>
@@ -37,28 +36,48 @@ require_once INCLUDE_DIR . 'class.queue.php';
     <div class="clear"></div>
  <?php csrf_token(); ?>
  <input type="hidden" name="do" value="mass_process" >
-<input type="hidden" id="action" name="a" value="" >
+ <input type="hidden" id="action" name="a" value="" >
  <table class="list" border="0" cellspacing="1" cellpadding="0" width="940">
     <thead>
         <tr>
             <th width="4%">&nbsp;</th>
-            <th width="46%"><a <?php echo $key_sort; ?> href="queues.php?t=tickets&amp;<?php echo $qstr; ?>&sort=name#queues"><?php echo __('Name');?></a></th>
-            <th width="12%"><a <?php echo $ip_sort; ?> href="queues.php?t=tickets&amp;<?php echo $qstr; ?>&sort=creator#queues"><?php echo __('Creator');?></a></th>
-            <th width="8%"><a  <?php echo $status_sort; ?> href="queues.php?t=tickets&amp;<?php echo $qstr; ?>&sort=status#queues"><?php echo __('Status');?></a></th>
-            <th width="10%" nowrap><a  <?php echo $date_sort; ?>href="queues.php?t=tickets&amp;<?php echo $qstr; ?>&sort=date#queues"><?php echo __('Created');?></a></th>
+            <th colspan="5" width="46%"><?php echo __('Name');?></th>
+            <th width="12%"><?php echo __('Creator');?></th>
+            <th width="8%"><?php echo __('Status');?></th>
+            <th width="10%" nowrap><?php echo __('Created');?></th>
         </tr>
     </thead>
-    <tbody>
-<?php foreach (CustomQueue::objects() as $q) { ?>
-    <tr>
-      <td><input type="checkbox" class="checkbox" name="ckb[]"></td>
-      <td><a href="queues.php?id=<?php echo $q->getId(); ?>"><?php
-        echo Format::htmlchars($q->getFullName()); ?></a></td>
-      <td><?php echo Format::htmlchars($q->staff->getName()); ?></td>
-      <td><?php echo Format::htmlchars($q->getStatus()); ?></td>
-      <td><?php echo Format::date($q->created); ?></td>
-    </tr>
+    <tbody class="sortable-rows" data-sort="qsort">
+<?php
+$all_queues = CustomQueue::objects()->all();
+$emitLevel = function($queues, $level=0) use ($all_queues, &$emitLevel) { 
+    $queues->sort(function($a) { return $a->sort; });
+    foreach ($queues as $q) { ?>
+      <tr>
+<?php if ($level) { ?>
+        <td colspan="<?php echo max(1, $level); ?>"></td>
 <?php } ?>
+        <td>
+          <input type="checkbox" class="checkbox" name="ckb[]">
+          <input type="hidden" name="qsort[<?php echo $q->id; ?>]"
+            value="<?php echo $q->sort; ?>"/>
+        </td>
+        <td colspan="<?php echo max(1, 5-$level); ?>"><a
+          href="queues.php?id=<?php echo $q->getId(); ?>"><?php
+          echo Format::htmlchars($q->getFullName()); ?></a></td>
+        <td><?php echo Format::htmlchars($q->staff->getName()); ?></td>
+        <td><?php echo Format::htmlchars($q->getStatus()); ?></td>
+        <td><?php echo Format::date($q->created); ?></td>
+      </tr>
+<?php
+        $children = $all_queues->findAll(array('parent_id' => $q->id));
+        if (count($children)) {
+            $emitLevel($children, $level+1);
+        }
+    }
+};
+
+$emitLevel($all_queues->findAll(array('parent_id' => 0)));
+?>
     </tbody>
 </table>
-</form>