C# Array sort question

Associate
Joined
30 Mar 2004
Posts
1,148
Location
West Wing
Hi,

I have an array of strings like this:

List<string> myList = new List<string>();
myList.add("Samuel, 01/09/2014");
myList.add("David, 15/08/2014");
myList.add("Alan, 19/08/2014");
myList.add("Ellen, 03/07/2014");
myList.add("Alan, 20/08/2014");

What i want to do is sort the array alphabetically by the name in the first part of the string without losing the associated date information.

Hope that makes sense, not sure if im going about this in the best way. Should i be using a different type of array? Or maybe create 2 separate arrays?

Appreciate any advice :)
 
Associate
OP
Joined
30 Mar 2004
Posts
1,148
Location
West Wing
Thanks, i didn't think of using the sort function.

Another question, how do I remove duplicates from the array? You can see in my first example there are 2 Alans.
 
Associate
OP
Joined
30 Mar 2004
Posts
1,148
Location
West Wing
I want to remove items that have the same name only. I.e. remove the second Alan, even though the date is different to the first Alan.
 
Back
Top Bottom