Tuesday, 20 August 2013

List Sorting with specific text and order based on user choice

List Sorting with specific text and order based on user choice

I would like to sort the following list based on prop1 first and then
based on the prop2 values of my choice. For example I would like sort the
list in ascending order using prop1 and then prop2 which contains the
value "application", then prop2 which contains the value "core" and then
then prop2 which contains the value "project"
IList<Test> tests = new List<Test>
{
new Test{prop1 = "Name1", prop2="project235"},
new Test{prop1 = "Name1", prop2="core222"},
new Test{prop1 = "Name1", prop2="application33331"},
new Test{prop1 = "Name1", prop2="project"},
new Test{prop1 = "Name1", prop2="application21"},
new Test{prop1 = "Name1", prop2="core1"},
new Test{prop1 = "Name1", prop2="application"},
new Test{prop1 = "Name2", prop2="application"},
new Test{prop1 = "Name2", prop2="core"},
new Test{prop1 = "Name2", prop2="project"}
};
The final output should look like this
Name1 application
Name1 application21
Name1 application33331
Name1 core1
Name1 core222
Name1 project
Name1 project235
Name2 application
Name2 core
Name2 project
Thank you in advance!!!!

No comments:

Post a Comment