unity sort a list
playerList.Sort((p1,p2)=>p1.score.CompareTo(p2.score));
unity sort a list
playerList.Sort((p1,p2)=>p1.score.CompareTo(p2.score));
unity3d sort list
// listVariable = The list of objects/vars etc.
// 'delegate' command - aka callback
// a / b - the values to compare
// N.B. possible return values are 1, 0 and -1. The .compare method
// can be used on multiple var types to ease sorting, e.g. int, float, string.
listVariable.Sort(delegate(ObjectType a, ObjectType b)
{
// E.g.
return string.Compare(a.param, b.param);
});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us