Created
January 24, 2015 07:01
-
-
Save snippe/3a08dd3b968651167e75 to your computer and use it in GitHub Desktop.
Sorting a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Person p1 = new Person() { Name = "Person 1", Age = 34 }; | |
Person p2 = new Person() { Name = "Person 2", Age = 31 }; | |
Person p3 = new Person() { Name = "Person 3", Age = 33 }; | |
Person p4 = new Person() { Name = "Person 4", Age = 26 }; | |
List<Person> people = new List<Person> { p1, p2, p3, p4 }; | |
//Exception : Failed to compare two elements in the array | |
people.Sort(); | |
} | |
} | |
public class Person | |
{ | |
public string Name { get; set; } | |
public int Age { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment