using System.Collections.Generic;
public static void Main(string[] args)
ContentKey a = new ContentKey() {key_num = 10};
ContentKey b = new ContentKey() {key_num = 20};
ContentKey c = new ContentKey() {key_num = 30};
SortedDictionary<ContentKey, string> dict = new SortedDictionary<ContentKey, string>(new KeyComparer());
foreach(var key_value in dict)
Console.WriteLine("Key val: " + key_value.Key.key_num + " Str: " + key_value.Value);
foreach(var key_value in dict)
Console.WriteLine("Key val: " + key_value.Key.key_num + " Str: " + key_value.Value);
public class KeyComparer : IComparer<ContentKey>
public int Compare(ContentKey a, ContentKey b)
return a.key_num.CompareTo(b.key_num);