I need to sort an ObservableCollection
after populatior alphabetically, suppose that inside I've this model:
class Nation
{
public string Name { get; set; }
}
and this is my ObservableCollection
:
ObservableCollection<Nation> ob = new ObservableCollection<Nation>();
suppose that inside I've three items with this order:
- England
- Afghanistan
- Italy
I need to sort it alphabetically, so I tried to:
ob.OrderBy(c => c.Name);
but I get no effect, when it should be:
- Afghanistan
- England
- Italy
What I did wrong?