From 9ecd4e2559c625dacbe60ce8a31690f1065c61d7 Mon Sep 17 00:00:00 2001 From: des Date: Mon, 7 Feb 2005 07:55:00 +0000 Subject: [PATCH] Sort branches in correct numeric order. --- tools/tools/tinderbox/www/index.cgi | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/tools/tinderbox/www/index.cgi b/tools/tools/tinderbox/www/index.cgi index 73d24b976a08..543e9b8235a5 100644 --- a/tools/tools/tinderbox/www/index.cgi +++ b/tools/tools/tinderbox/www/index.cgi @@ -54,6 +54,31 @@ sub success($) { return undef; } +sub branch_sort($$) { + my ($a, $b) = @_; + + my @a = split('_', $a); + my @b = split('_', $b); + while (@a || @b) { + ($a, $b) = (shift(@a), shift(@b)); + return 1 unless defined($a); + return -1 unless defined($b); + next if $a eq $b; + if ($a =~ m/^\d+$/ && $b =~ m/^\d+$/) { + return $a <=> $b; + } else { + return $a cmp $b; + } + } + return 0; +} + +sub inverse_branch_sort($$) { + my ($a, $b) = @_; + + return branch_sort($b, $a); +} + sub do_config($) { my $config = shift; @@ -75,7 +100,7 @@ sub do_config($) { my $now = time(); - foreach my $branch (sort(keys(%branches))) { + foreach my $branch (sort(inverse_branch_sort keys(%branches))) { my $html = " $branch ";