Unity/Csharp/linq
提供: 初心者エンジニアの簡易メモ
準備
using System.Linq;
順序
User[] users = new User[] { new User() { age = 10, name = "taro" }, new User() { age = 13, name = "jiro" }, new User() { age = 12, name = "saburo" }, new User() { age = 15, name = "siro" }, }; // 年下順 IOrderedEnumerable<Parameter> orderedUsers = users.OrderBy( value => value.age ); // 年上順 IOrderedEnumerable<Parameter> orderedUsers = users.OrderByDescending( value => value.age );