Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# how to sort a list

var simpleList = new List<ObjectName>();
// Order by a property
list.OrderBy(o => o.PropertyName);
// Order by multiple property
list.OrderBy(o => o.PropertyName).ThenBy(o => o.AnotherProperty);
// Same but descending
list.OrderByDescending(o => o.PropertyName).ThenByDescending(o => o.AnotherProperty);
Comment

sorting a list of objects in c#

List<Order> SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();
List<Order> DescSortedList = objListOrder.OrderByDescending(o=>o.OrderDate).ToList();
Comment

list sort c#

List<Order> SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();
Comment

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;
});
Comment

sort list c# by string

ListObject = ListObject.OrderBy(item => item.Property).ToList();
Comment

c# sort llist

List<Order> SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();
Comment

PREVIOUS NEXT
Code Example
Csharp :: system.windows.forms not found 
Csharp :: C# tolower all in a array 
Csharp :: httpclient post c# example 
Csharp :: c# datagridview selected row index 
Csharp :: convert string to int c# 
Csharp :: unity c# check how many of an object exists 
Csharp :: System command c# 
Csharp :: selection sort in c# 
Csharp :: movetowards unity 
Csharp :: C# calculate sum of digits of a number 
Csharp :: c# lambda join two tables 
Csharp :: c# contains 
Csharp :: unity raycast 2d 
Csharp :: gameobject on click unity 
Csharp :: doing void when gameobject setactive unity 
Csharp :: Net.ServicePointManager.SecurityProtocol .net framework 4 
Csharp :: raycasting in unity 
Csharp :: c# int to string 
Csharp :: c# last char in string 
Csharp :: c# best tutorial 
Csharp :: billboard canvas unity 
Csharp :: public gameobject unity 
Csharp :: build cs file 
Csharp :: unity custom editor 
Csharp :: delegate in c# 
Csharp :: c# function return 
Csharp :: on collision enter by layer 2d unity 
Csharp :: transform.position.x unity 
Csharp :: c# enum 
Csharp :: c# right function 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =