I have a question regarding sorting in C#.
Lets assume that there is List<Person> personList with 50 items.
Each Person has string forename, surname.
Now I would like to sort this list of persons.
First of all the list shall be sorted by the Forename.
Therefor I would use this:
personList.Sort((p1, p2)=>string.Compare(p1.Forename, p2.Forname, true));
After this I would like to sort all entries with the same Forname by their Surname.
How can I do this?
Edit:
@Russ Cam: Here is an example list.
Unsorted:
David Johnson
William Black
David Smith
Matthew Edwards
Jayden Anderson
Andrew Connor
Adam Johnson
Daniel Armstrong
Steve Anderson
Daniel Black
Sorted:
Adam Johnson
Andrew Connor
Daniel Armstrong
Daniel Black
David Johnson
David Smith
Jayden Anderson
Matthew Edwards
Steve Anderson
William Black
this works perfectly