I have two lists of the same type of object.
One list comes from the system administrators, and the other comes from the user viewing the page.
These lists must be merged for viewing at some point and it is likely that the value position which the lists are sorted on will have conflicting values.
Is there a way to merge the two lists, and when identical values are found for position, to give the lower (and therefore better) spot to the admin list?
EXAMPLE
class info
{
int position;
string title;
}
List<info> adminInfo = new List<info>
{
new info() {position = 0, title = "adminOne"}
new info() {position = 4, title = "adminThree"}
new info() {position = 3, title = "adminTwo"}
}
List<info> userInfo = new List<info>
{
new info() {position = 0, title = "userOne"}
new info() {position = 3, title = "userTwo"}
}
List<info> PreferentiallySortedList(List<info> adminList, List<info> userList)
{
//Some kind of magic here
}
//Looping through PreferentiallySortedList and displaying
//the title of each item should return the following:
"adminOne"
"userOne"
"adminTwo"
"userTwo"
"adminThree"
The easiest way (code-wise) is to use LINQ with a Union and create a new anonymous class that contains a priority and the
info.Something like this (may have syntax errors)