Skip to content

Instantly share code, notes, and snippets.

@baobao
Created October 8, 2014 02:32
Show Gist options
  • Save baobao/4e72ca36e272c65a262d to your computer and use it in GitHub Desktop.
Save baobao/4e72ca36e272c65a262d to your computer and use it in GitHub Desktop.
C#ソート関数
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