Make your object something like
public class MyObject : IComparable
{
public string a;
public string b;
virtual public int CompareTo(object obj)
{
if (obj is MyObject)
{
var compareObj = (MyObject)obj;
if (this.a.CompareTo(compareObj.a) == 0)
{
// compare second value
return this.b.CompareTo(compareObj.b);
}
return this.a.CompareTo(compareObj.b);
}
else
{
throw new ArgumentException("Object is not a MyObject ");
}
}
}
also note that the returns for CompareTo :
http://msdn.microsoft.com/en-us/library/system.icomparable.compareto.aspx
Then, if you have a List of MyObject, call .Sort() ie
var objList = new List<MyObject>();
objList.Sort();