I need to sort a collection. For example, I have
Austin 12/3/2012
Sam 100 12/3/2012
Sam 200 14/3/2012
Bubly 300 12/3/2012
Bubly 300 15/3/2012
I would create a class to hold your information
public class NameDate
{
private string name;
private DateTime date;
public string Name
{
get { return name; }
set { name = value; }
}
public DateTime Date
{
get { return date; }
set { date = value; }
}
}
I would then populate a List to hold your items. When this is done, to sort the items you can use LINQ
List someList = new List();
someList = GetNameDateList();
var orderedByNameList = someList.OrderBy(e => e.Name);
var orderedByDateTimeList = someList.OrderBy(e => e.Date);
I hope this helps.