Hi, I want to sort the data accordinf to the 3rd column which I can but I need to leave the entire heading row intact which means I need to skip a row, dont know how, Also I need distinct data for the 3rd row which means (bim is diff than BIm). I can only
get 4 rows to display, how do i get to display the rest. Here is my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
var records = (from l in File.ReadAllLines(@"d:\instance_test.txt")
let pieces = l.Split('\t')
select new { Col1 = pieces[0], Col2 = pieces[1], Col3 = pieces[2], Col4 = pieces[3] })
.GroupBy(c => (c.Col1 + c.Col2 + c.Col3+c.Col4))
.Skip(1)
.Select(gr => gr.First())
.Distinct()
.OrderBy(c => c.Col3);
for (int i = 0; i < 99; i++)
{
} foreach (var r in records)
{ Console.WriteLine("{0}, {1}, {2},{3}", r.Col1, r.Col2, r.Col3, r.Col4); }
Console.WriteLine();
Console.WriteLine("Done");
Console.ReadLine();
}
}
}