Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 0a5d946

Browse files
committed
Merge pull request #223 from linquize/project-grid-test
ProjectGrid switches to a stable sort algorithm
2 parents 0ced9ff + 128459d commit 0a5d946

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

project/UnitTests/WebDashboard/Dashboard/ProjectGridTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ public void ShouldReturnProjectsSortedByCategoryIfCategoryColumnSpecifiedAsSortS
644644

645645
// Verify
646646
Assert.AreEqual(3, rows.Length);
647-
Assert.AreEqual("C", rows[0].Name);
648-
Assert.AreEqual("A", rows[1].Name);
647+
Assert.AreEqual("A", rows[0].Name);
648+
Assert.AreEqual("C", rows[1].Name);
649649
Assert.AreEqual("B", rows[2].Name);
650650

651651
// Setup
@@ -659,8 +659,8 @@ public void ShouldReturnProjectsSortedByCategoryIfCategoryColumnSpecifiedAsSortS
659659
// Verify
660660
Assert.AreEqual(3, rows.Length);
661661
Assert.AreEqual("B", rows[0].Name);
662-
Assert.AreEqual("C", rows[1].Name);
663-
Assert.AreEqual("A", rows[2].Name);
662+
Assert.AreEqual("A", rows[1].Name);
663+
Assert.AreEqual("C", rows[2].Name);
664664

665665
VerifyAll();
666666
}

project/WebDashboard/Dashboard/ProjectGrid.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using ThoughtWorks.CruiseControl.Core.Reporting.Dashboard.Navigation;
34
using ThoughtWorks.CruiseControl.Remote;
45
using ThoughtWorks.CruiseControl.WebDashboard.Plugins.ProjectReport;
@@ -31,9 +32,7 @@ public ProjectGridRow[] GenerateProjectGridRows(ProjectStatusOnServer[] statusLi
3132
translations));
3233
}
3334

34-
rows.Sort(GetComparer(sortColumn, sortIsAscending));
35-
36-
return rows.ToArray();
35+
return rows.OrderBy(a => a, GetComparer(sortColumn, sortIsAscending)).ToArray();
3736
}
3837

3938
private IComparer<ProjectGridRow> GetComparer(ProjectGridSortColumn column, bool ascending)

0 commit comments

Comments
 (0)