111,094
社区成员




struct KeyValue
{
public string key { set; get; }
public int value { set; get; }
public KeyValue(string k,int v)
{
key = k;
value = v;
}
}
List<KeyValue> dic = new List<KeyValue>();
dic.Add(new KeyValue("c", 100));
dic.Add(new KeyValue("a", -2));
dic.Add(new KeyValue("b", 40));
KeyValue temp;
int len = dic.Count;
for (int i = 0; i < len - 1; i++)
{
for (int j = 0; j < len - i - 1; j++)
{
if (dic[j].value>dic[j+1].value)
{
temp = dic[j];
dic[j] = dic[j + 1];
dic[j + 1] = temp;
}
}
}