While developing Windows 8 applications I have come across the requirement to have my list of items sorted on my screen, sometimes in a <ListBox>. Unfortunately the base WinRT controls make this really difficult to achieve.

After a few hours of searching for an easier way to do it, I finally discovered a way of sorting the items. Rather than having the controls automatically sort for me (as I was used to doing in Silverlight, etc.), but instead by sorting the underlying list itself. It makes total sense in hindsight.

A blog post from Andrea Boschin explains how to do it: http://www.xamlplayground.org/post/2010/04/27/Keeping-an-ObservableCollection-sorted-with-a-method-override.aspx

The sorting can be achieved automatically by overriding a method in the ObservableCollection. The final step is to add the IComparable interface to the class you want to sort.

Here is an example IComparable implementation that will sort alphabetically

public int CompareTo(object obj)
var person = obj as Person;
return string.CompareOrdinal(this.Name, person.Name);

By David Burela
Reblogged from my 
Infragistics blog