diff --git a/xhprof_lib/utils/xhprof_runs.php b/xhprof_lib/utils/xhprof_runs.php
index cde5ff55..a3d40c04 100644
--- a/xhprof_lib/utils/xhprof_runs.php
+++ b/xhprof_lib/utils/xhprof_runs.php
@@ -148,11 +148,33 @@ public function save_run($xhprof_data, $type, $run_id = null) {
function list_runs() {
if (is_dir($this->dir)) {
- echo "
Existing runs:\n\n";
+ echo "
Existing runs:
\n";
$files = glob("{$this->dir}/*.{$this->suffix}");
- usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
+
+ $sort_function = function($a, $b){
+ list($tmp,$source_a) = explode('.', basename($a));
+ list($tmp,$source_b) = explode('.', basename($b));
+
+ if ($source_a == $source_b) {
+ return filemtime($b) - filemtime($a);
+ }
+
+ return $source_a > $source_b;
+ };
+
+ usort($files, $sort_function);
+
+ $oldSource=null;
+
foreach ($files as $file) {
list($run,$source) = explode('.', basename($file));
+ if ($oldSource != $source) {
+ if (null !== $oldSource) {
+ echo "
\n";
+ }
+ echo "$source";
+ $oldSource = $source;
+ }
echo '- '