With help here:
http://stackoverflow.com/questions/14661719/sorting-and-grouping#comment20496411_14661719 I archieved the sorting part. In the source code I changed:
if (template.GroupTemplate.Contains("{PRODUCT TAG}"))
{
var groups = lines.GroupBy(GetMenuItemTag);
var result = new List<string>();
foreach (var grp in groups)
{
var grpSep = template.GroupTemplate.Replace("{PRODUCT TAG}", grp.Key);
result.AddRange(grpSep.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries));
result.AddRange(grp.SelectMany(x => FormatLines(template, x).Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)));
}
return result;
}
Into
if (template.GroupTemplate.Contains("{PRODUCT TAG}"))
{
var groups = lines.GroupBy(GetMenuItemTag).OrderBy(l => l.Key);
var result = new List<string>();
foreach (var grp in groups)
{
var grpSep = template.GroupTemplate.Replace("{PRODUCT TAG}", grp.Key);
result.AddRange(grpSep.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries));
result.AddRange(grp.SelectMany(x => FormatLines(template, x).Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)));
}
return result;
}
If I tag the product now like "1 Starter" "2 Main course" "3 desert" I get the items in the right order on the ticket.
Do you have any hint on grouping the articles on the tickets? I mean that 1 x coffee 2x coffee becomes 3 x coffee?