using System; using System.Collections.Generic; class Program { static string InputPattern = "Input4"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("4"); WillReturn.Add("H2 D2 S2 C2"); //D2 C2 H2 S2 } else if (InputPattern == "Input2") { WillReturn.Add("5"); WillReturn.Add("ST SA SK SQ SJ"); //SA ST SJ SQ SK } else if (InputPattern == "Input3") { WillReturn.Add("6"); WillReturn.Add("S4 SA C5 C4 CA DA"); //DA CA C4 C5 SA S4 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); string[] CardArr = InputList[1].Split(' '); int UB = CardArr.GetUpperBound(0); Array.Sort(CardArr, (A, B) => { int A_P1 = DeriveMarkPriority(A), A_P2 = DeriveNumPriority(A); int B_P1 = DeriveMarkPriority(B), B_P2 = DeriveNumPriority(B); int wkInt = A_P1.CompareTo(B_P1); if (wkInt != 0) return wkInt; return A_P2.CompareTo(B_P2); }); Console.WriteLine(string.Join(" ", CardArr)); } //マークのプライオリティを返す static int DeriveMarkPriority(string pStr) { if (pStr[0] == 'D') return 1; if (pStr[0] == 'C') return 2; if (pStr[0] == 'H') return 3; if (pStr[0] == 'S') return 4; return 0; } //数字のプライオリティを返す static int DeriveNumPriority(string pStr) { if (pStr[1] == 'A') return 1; if (pStr[1] == 'T') return 10; if (pStr[1] == 'J') return 11; if (pStr[1] == 'Q') return 12; if (pStr[1] == 'K') return 13; return pStr[1] - '2' + 2; } }