Order a List based on values in another List

  • Thread starter Thread starter nothingisimpossible
  • Start date Start date
N

nothingisimpossible

Guest
Class:

public class Item
{

public decimal Id
{
get; set;
}



public string Name
{
get; set;
}

}

My Code:

Main()
{

//Source List
IList<Item> Items = new List<Item>();

Items.Add( new Item() {Id = 10, Name = 'X'});
Items.Add( new Item() {Id = 11, Name = 'Y'});
Items.Add( new Item() {Id = 12, Name = 'Z'});
Items.Add( new Item() {Id = 13, Name = 'A'});

//Comparing list
// The below list contains Ids but not in a different order compared to the above list
IList<decimal> Ids = new List<Item>(decimal);

Ids.Add(12);
Ids.Add(10);
Ids.Add(13);
Ids.Add(11);


}

Requirement:

Using C# -- I would like to order source list 'Items' based on the 'Id' property but the 'Id' values should come from Comparing list 'Ids'.

Thanks

Continue reading...
 
Back
Top