1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void Main() { var list = new List<string>{"1_to_2", "0_to_1", "10_to_11", "3_to_4", "5_to_6", "4_to_5", "2_to_3"}; list.Sort(LessThan); list.Dump(); } public int LessThan(string first, string second) { var firstInt = Int32.Parse(GetFirstBit(first)); var secondInt = Int32.Parse(GetFirstBit(second)); if (firstInt == secondInt) return 0; if (firstInt < secondInt) return -1; return 1; }
You can clone a snippet to your computer for local editing. Learn more.