using System;
using System.Globalization;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Test
{
class grpitem
{
public string groupCode;
public string item;
}
static List<grpitem> list = new List<grpitem>()
{
new grpitem() {groupCode="3", item="b"},
new grpitem() {groupCode="1", item="b"},
new grpitem() {groupCode="3", item="c"},
new grpitem() {groupCode="2", item="b"},
new grpitem() {groupCode="2", item="a"},
new grpitem() {groupCode="2", item="c"},
new grpitem() {groupCode="1", item="a"},
new grpitem() {groupCode="3", item="a"},
new grpitem() {groupCode="3", item="d"}
};
public static void Main()
{
IEnumerable<grpitem> ordered = list.GroupBy(grp => grp.groupCode)
.SelectMany(g => g.OrderBy(grp => grp.item));
foreach(grpitem g in ordered)
Console.WriteLine("groupCode:{0} item:{1}",g.groupCode,g.item);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uR2xvYmFsaXphdGlvbjsKdXNpbmcgU3lzdGVtLkxpbnE7CnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9uczsKdXNpbmcgU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWM7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CgkJY2xhc3MgZ3JwaXRlbQoJICAgIHsKCSAgICAgICAgcHVibGljIHN0cmluZyBncm91cENvZGU7CgkgICAgICAgIHB1YmxpYyBzdHJpbmcgaXRlbTsKCSAgICB9CiAgICAgICAgCiAgICAgICAgc3RhdGljIExpc3Q8Z3JwaXRlbT4gbGlzdCA9IG5ldyBMaXN0PGdycGl0ZW0+KCkKICAgICAgICB7CiAgICAgICAgICAgICBuZXcgZ3JwaXRlbSgpIHtncm91cENvZGU9IjMiLCBpdGVtPSJiIn0sCiAgICAgICAgICAgICBuZXcgZ3JwaXRlbSgpIHtncm91cENvZGU9IjEiLCBpdGVtPSJiIn0sCiAgICAgICAgICAgICBuZXcgZ3JwaXRlbSgpIHtncm91cENvZGU9IjMiLCBpdGVtPSJjIn0sCiAgICAgICAgICAgICBuZXcgZ3JwaXRlbSgpI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