Created
October 8, 2014 02:32
-
-
Save baobao/4e72ca36e272c65a262d to your computer and use it in GitHub Desktop.
C#ソート関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SortTest { | |
void Start () | |
{ | |
List<Foo> a = new List<Foo> (); | |
a.Add (new Foo (1)); | |
a.Add (new Foo (100)); | |
a.Add (new Foo (30)); | |
a.Add (new Foo (20)); | |
a.Add (new Foo (99)); | |
for (int i = 0; i < a.Count; i++) { | |
Debug.LogError (a [i].a); | |
} | |
Debug.LogError ("==============="); | |
a.Sort ((x, y) => { | |
int flg = 0; | |
int xx = x.a; | |
int yy = y.a; | |
Debug.LogError ("xx : " + xx + " yy : " + yy); | |
return 1; | |
}); | |
for (int i = 0; i < a.Count; i++) { | |
Debug.LogError (a [i].a); | |
} | |
} | |
class Foo | |
{ | |
public int a; | |
public Foo (int a) | |
{ | |
this.a = a; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment