Created
December 11, 2015 19:14
-
-
Save Collonville/66a0837cc6e1ac878437 to your computer and use it in GitHub Desktop.
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 Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<Player> foo = new List<Player> | |
{ | |
new Player(100, "Miku"), | |
new Player(350, "Ren"), | |
new Player(700, "Yukarin"), | |
new Player(3500, "IA") | |
}; | |
var sortedByHp = foo.OrderBy(e => e.hp); //sort hp | |
var sortedByName = foo.OrderBy(e => e.name); //sort name | |
sortedByHp.ToList().ForEach(x => Console.WriteLine(x.hp)); //show | |
sortedByName.ToList().ForEach(x => Console.WriteLine(x.name)); //show | |
} | |
} | |
class Player | |
{ | |
public int hp; | |
public string name; | |
public Player(int hp, string name) | |
{ | |
this.hp = hp; | |
this.name = name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment