I'm trying to have LINQ sort a list then remove unnecessary items on it.
class Item {
public float time;
public int level;
public Item(int l, float t) {
time = t;
level = l;
}
}
List<Item> items = new List<Item>();
items.Add(new Item(1, 1f));
items.Add(new Item(2, 2f));
items.Add(new Item(3, 3f));
items.Add(new Item(3, 4f));
items.Add(new Item(2, 5f));
I need to take items in this list from highest level and after time value result should be:
Item { level = 3, time = 4f }
Item { level = 2, time = 5f }
Can I do that with LINQ?