先是 Y_FaceItem类
using DlibDotNet; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Y_FaceItem : MonoBehaviour { public float finalValue; public Texture2D faceTextrue; public int id; public string faceImage; public Matrix<float> code; }
然后是排序的应用方法
List<Y_FaceItem> itemList = new List<Y_FaceItem>(); Y_FaceItem item = new Y_FaceItem(); item.finalValue = 39; Y_FaceItem item1 = new Y_FaceItem(); item1.finalValue = 19; Y_FaceItem item2 = new Y_FaceItem(); item2.finalValue = 29; //itemList.Add(item as Y_FaceItem); //itemList.Add(item1 as Y_FaceItem); //itemList.Add(item2 as Y_FaceItem); itemList.Add(item ); itemList.Add(item1 ); itemList.Add(item2 ); Debug.LogError("AAAAAAAAAAAAAAA"); foreach (var _i in itemList) { Debug.LogError(_i.finalValue); } Debug.LogError("BBBBBBBBBBBBBB"); var sortlist = itemList.OrderBy(o => o.finalValue).ToList();//升序 foreach (var _i in sortlist) { Debug.LogError(_i.finalValue); } Debug.LogError("CCCCCCCCCCCCC"); var sortlist1 = itemList.OrderByDescending(o => o.finalValue).ToList();//降序 foreach (var _i in sortlist1) { Debug.LogError(_i.finalValue); } Debug.LogError("DDDDDDDDDDDDD"); foreach (var _i in itemList) { Debug.LogError(_i.finalValue); }
标签:LogError,FaceItem,C#,finalValue,List,Add,itemList,Debug,排序 From: https://www.cnblogs.com/lingLuoChengMi/p/18085394