diff --git a/performance/performance.module b/performance/performance.module
index fd46742..6711abe 100644
--- a/performance/performance.module
+++ b/performance/performance.module
@@ -398,13 +398,28 @@ function performance_apc_list_all() {
 /**
  * Custom sort for summary performance report
  *
- * @param $x
- * @param $y
- * @return int
+ * @param $array
+ * The table array to be sorted
+ * @param $tablesort
+ * The results of tablesort_init() on the table's headers
+ * @return array
+ * The sorted version of $array
  */
-function performance_summary_sort($x, $y) {
-  // This function is not working
-  return 0;
+function _performance_sort($array, $tablesort) {
+  $sort_field = $tablesort['sql'];
+  $tmp = array();
+  foreach ($array as $index => $data) {
+    $tmp[$index] = $data[$sort_field];
+  }
+
+  $arguments = array(
+    $tmp,
+    $tablesort['sort'] == 'desc' ? SORT_DESC : SORT_ASC,
+    &$array,
+                     );
+  call_user_func_array('array_multisort', $arguments);
+  $results = array_pop($arguments);
+  return $results;
 }
 
 function performance_view_summary() {
@@ -454,7 +469,7 @@ function performance_view_summary() {
         }
       }
     }
-    usort($data_list, 'performance_summary_sort');
+    $data_list = _performance_sort($data_list, $tablesort);
   }
   else if (variable_get('performance_summary_apc', 0) && function_exists('apc_cache_info')) {
     $tablesort = tablesort_init($header);
@@ -462,7 +477,7 @@ function performance_view_summary() {
     foreach (performance_apc_list_all() as $key) {
       $data_list[] = apc_fetch($key) + $tablesort;
     }
-    usort($data_list, 'performance_summary_sort');
+    $data_list = _performance_sort($data_list, $tablesort);
   }
   else {
     // Get the data form the database table
