Aditya Patil

Aditya Patil

  • NA
  • 535
  • 134.8k

URGENT: Sort by Group By in C# Console Application

Jul 14 2014 2:35 AM
List<Program> income = new List<Program>();
List<Program> incomeSorted = new List<Program>();
Console.WriteLine("Income");
Console.WriteLine("Predefined Category:");
for (i = 0; i < 2;i++)
{
for (j = 0; j < 2;j++)
{
Console.WriteLine("\n Predefined Category Selection: (Only Category ID.)");
icategory[i,j] = Console.ReadLine();
Console.WriteLine("\n Title:");
ititle[i,j] = Console.ReadLine();
Console.WriteLine("\n Amount:");
iamount[i,j] = int.Parse(Console.ReadLine());
Console.WriteLine("\n Date:");
idate[i, j] = DateTime.Parse(Console.ReadLine());
income.Add(new Program
{
icategory = icategory[i, j],
ititle = ititle[i, j],
iamount = iamount[i, j],
idate = idate[i, j],
});
}
}
Here by above code I took the data from User by array and added in List Income, Now I want to sort this Income list as below options
1. Sort by date
2. Sort by name
3. Group by category 
Now how I can do that? can anyone give code in C# for this?

Answers (4)