Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# sort list<>

var users = new List<User>();
users.Add(new User("John", "Doe", 1230));
users.Add(new User("Lucy", "Novak", 670));
users.Add(new User("Ben", "Walter", 2050));
users.Add(new User("Robin", "Brown", 2300));
users.Add(new User("Amy", "Doe", 1250));
users.Add(new User("Joe", "Draker", 1190));
users.Add(new User("Janet", "Doe", 980));
users.Add(new User("Albert", "Novak", 1930));
users.Sort((u1, u2) =>
{
    int result = u1.LastName.CompareTo(u2.LastName);
    return result == 0 ? u1.Salary.CompareTo(u2.Salary) : result;
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort
ADD COMMENT
Topic
Name
5+7 =