using System;
using System.Linq;
public class Program
{
public static void Main()
var numbers = new int[] { 1 ,2, 3, 4, 5, 6, 7, 3, 3, 4, 6, 2, 4, 6, 3, 4, 7, 2, 7, 4 };
var result = numbers.GroupBy(o => o).Select(o => new { count=o.Count(), key = o.Key }).OrderBy(o => o.count).ThenBy(o => o.key);
Console.WriteLine(string.Join(",", result.Select(o => o.ToString())));
}