Index: html/includes/entities/mempool.inc.php
===================================================================
--- html/includes/entities/mempool.inc.php	(revision 7689)
+++ html/includes/entities/mempool.inc.php	(working copy)
@@ -58,7 +58,35 @@
       $mempools[] = $mempool;
     }
   }
-  $mempools = array_sort_by($mempools, 'hostname', SORT_ASC, SORT_STRING, 'mempool_descr', SORT_ASC, SORT_STRING);
+
+  // Sorting
+  // FIXME. Sorting can be as function, but in must before print_table_header and after get table from db
+  switch ($vars['sort_order'])
+  {
+    case 'desc':
+      $sort_order = SORT_DESC;
+      $sort_neg   = SORT_ASC;
+      break;
+    case 'reset':
+      unset($vars['sort'], $vars['sort_order']);
+      // no break here
+    default:
+      $sort_order = SORT_ASC;
+      $sort_neg   = SORT_DESC;
+  }
+  switch($vars['sort'])
+  {
+    case 'usage':
+      $mempools = array_sort_by($mempools, 'mempool_perc', $sort_neg, SORT_NUMERIC);
+      break;
+    case 'used':
+      $mempools = array_sort_by($mempools, 'mempool_'.$vars['sort'], $sort_neg, SORT_NUMERIC);
+      break;
+    default:
+      $mempools = array_sort_by($mempools, 'hostname', $sort_order, SORT_STRING, 'mempool_descr', $sort_order, SORT_STRING);
+      break;
+  }
+
   $mempools_count = count($mempools);
 
   // Pagination
@@ -81,7 +109,7 @@
     print_mempool_row($mempool, $vars);
   }
 
-  echo("</table>");
+  echo("</tbody></table>");
 
   echo generate_box_close();
 
@@ -91,31 +119,30 @@
 
 function print_mempool_table_header($vars)
 {
-
   if ($vars['view'] == "graphs")
   {
-    $stripe_class = "table-striped-two";
+    $table_class = OBS_CLASS_TABLE_STRIPED_TWO;
+  } else {
+    $table_class = OBS_CLASS_TABLE_STRIPED;
   }
-  else
-  {
-    $stripe_class = "table-striped";
-  }
 
-  echo '<table class="table ' . $stripe_class . '  table-condensed">';
-  echo '  <thead>';
-  echo '    <tr>';
-  echo '      <th class="state-marker"></th>';
-  if ($vars['page'] != "device")
+  echo('<table class="' . $table_class . '">' . PHP_EOL);
+  $cols = array(
+                   array(NULL, 'class="state-marker"'),
+    'device'    => array('Device', 'style="width: 200px;"'),
+    'descr'     => array('Memory'),
+                   array('', 'style="width: 100px;"'),
+    'usage'     => array('Usage', 'style="width: 280px;"'),                   
+    'used'      => array('Used', 'style="width: 50px;"'),
+  );
+
+  if ($vars['page'] == "device")
   {
-    echo '      <th style="width: 200px;">Device</th>';
+    unset($cols['device']);
   }
-  echo '      <th>Memory</th>';
-  echo '      <th style="width: 100px;"></th>';
-  echo '      <th style="width: 280px;">Usage</th>';
-  echo '      <th style="width: 50px;">Used</th>';
-  echo '    </tr>';
-  echo '  </thead>';
 
+  echo(get_table_header($cols, $vars));
+  echo('<tbody>' . PHP_EOL);
 }
 
 function print_mempool_row($mempool, $vars)
Index: html/includes/entities/processor.inc.php
===================================================================
--- html/includes/entities/processor.inc.php	(revision 7689)
+++ html/includes/entities/processor.inc.php	(working copy)
@@ -54,7 +54,31 @@
     }
   }
 
-  $processors = array_sort_by($processors, 'hostname', SORT_ASC, SORT_STRING, 'processor_descr', SORT_ASC, SORT_STRING);
+  // Sorting
+  // FIXME. Sorting can be as function, but in must before print_table_header and after get table from db
+  switch ($vars['sort_order'])
+  {
+    case 'desc':
+      $sort_order = SORT_DESC;
+      $sort_neg   = SORT_ASC;
+      break;
+    case 'reset':
+      unset($vars['sort'], $vars['sort_order']);
+      // no break here
+    default:
+      $sort_order = SORT_ASC;
+      $sort_neg   = SORT_DESC;
+  }
+  switch($vars['sort'])
+  {
+    case 'usage':
+      $processors = array_sort_by($processors, 'processor_usage', $sort_neg, SORT_NUMERIC);
+      break;
+    default:
+      $processors = array_sort_by($processors, 'hostname', $sort_order, SORT_STRING, 'processor_descr', $sort_order, SORT_STRING);
+      break;
+  }
+
   $processors_count = count($processors);
 
   // Pagination
@@ -77,7 +101,7 @@
     print_processor_row($processor, $vars);
   }
 
-  echo("</table>");
+  echo("</tbody></table>");
 
   echo generate_box_close();
 
@@ -87,19 +111,29 @@
 
 function print_processor_table_header($vars)
 {
-  if ($vars['view'] == "graphs") { $stripe_class = "table-striped-two"; } else { $stripe_class = "table-striped"; }
+  if ($vars['view'] == "graphs")
+  {
+    $table_class = OBS_CLASS_TABLE_STRIPED_TWO;
+  } else {
+    $table_class = OBS_CLASS_TABLE_STRIPED;
+  }
 
-  echo('<table class="table '.$stripe_class.' table-condensed ">');
-  echo('  <thead>');
-  echo('    <tr>');
-  echo('      <th class="state-marker"></th>');
-  if ($vars['page'] != "device") { echo('      <th style="width: 200px;">Device</th>'); }
-  echo('      <th>Processor</th>');
-  echo('      <th style="width: 100px;"></th>');
-  echo('      <th style="width: 250px;">Usage</th>');
-  echo('    </tr>');
-  echo('  </thead>');
+  echo('<table class="' . $table_class . '">' . PHP_EOL);
+  $cols = array(
+                   array(NULL, 'class="state-marker"'),
+    'device'    => array('Device', 'style="width: 200px;"'),
+    'descr'     => array('Processor'),
+                   array('', 'style="width: 100px;"'),
+    'usage'     => array('Usage', 'style="width: 250px;"'),
+  );
 
+  if ($vars['page'] == "device")
+  {
+    unset($cols['device']);
+  }
+
+  echo(get_table_header($cols, $vars));
+  echo('<tbody>' . PHP_EOL);
 }
 
 function print_processor_row($processor, $vars)
Index: html/includes/entities/storage.inc.php
===================================================================
--- html/includes/entities/storage.inc.php	(revision 7689)
+++ html/includes/entities/storage.inc.php	(working copy)
@@ -65,20 +65,20 @@
     }  
     switch($vars['sort'])
     {
-        case 'usage':
-            $storages = array_sort_by($storages, 'storage_perc', $sort_order, SORT_STRING);
-            break;
-        case 'mountpoint':
-            $storages = array_sort_by($storages, 'storage_descr', $sort_order, SORT_STRING);
-            break;
-        case 'size':
-        case 'free':
-        case 'used':
-            $storages = array_sort_by($storages, 'storage_'.$vars['sort'], $sort_neg, SORT_NUMERIC);
-            break;
-        default:
-            $storages = array_sort_by($storages, 'hostname', $sort_order, SORT_STRING, 'storage_descr', $sort_order, SORT_STRING);
-            break;
+      case 'usage':
+        $storages = array_sort_by($storages, 'storage_perc', $sort_neg, SORT_NUMERIC);
+        break;
+      case 'mountpoint':
+        $storages = array_sort_by($storages, 'storage_descr', $sort_order, SORT_STRING);
+        break;
+      case 'size':
+      case 'free':
+      case 'used':
+        $storages = array_sort_by($storages, 'storage_'.$vars['sort'], $sort_neg, SORT_NUMERIC);
+        break;
+      default:
+        $storages = array_sort_by($storages, 'hostname', $sort_order, SORT_STRING, 'storage_descr', $sort_order, SORT_STRING);
+        break;
     }    
     
     $storages_count = count($storages);
@@ -117,12 +117,12 @@
 {
   if ($vars['view'] == "graphs" || isset($vars['graph']))
   {
-    $stripe_class = "table-striped-two";
+    $table_class = OBS_CLASS_TABLE_STRIPED_TWO;
   } else {
-    $stripe_class = "table-striped";
+    $table_class = OBS_CLASS_TABLE_STRIPED;
   }
 
-  echo('<table class="table ' . $stripe_class . ' table-condensed ">' . PHP_EOL);
+  echo('<table class="' . $table_class . '">' . PHP_EOL);
   $cols = array(
                     array(NULL, 'class="state-marker"'),
     'device'     => array('Device', 'style="width: 250px;"'),