If you just need the object one time you can make an anonymous class, this would make what you are trying to do a lot clearer in your code
var firstSplit = allText.Split(new[]{Environment.NewLine},
SplitOptions.RemoveEmptyEntries);
var dataLines = (from i in firstSplit
let currLine = i.Split(new[]{" "},SplitOptions.RemoveEmptyEntries)
select new
{
FirstName = currLine [0],
LastName = currLine [1],
DateTime = DateTime.ParseExact(currLine[2]+currLine[3],
"MM/dd/yyyy hh.mmtt")
}).OrderBy(s=>s.FirstName);
foreach(var line in dataLines)
Console.WriteLine("{0} {1} {2}", line.FirstName,
line.LastName,
line.DateTime.ToString("MM/dd/yyyy hh.mmtt"));
or you could just use linq to select a jagged array with the same method, and sort on the whatever field you are looking for, but only if you want to sort based off of alphabetical order.
var fsplt = allText.Split(new{Environment.NewLine},
StringSplitOptions.RemoveEmptyEntries );
var dataLines = from line in fsplit
let currLine = line.Split(new[]{" "},SplitOptions.RemoveEmptyEntries)
orderby currLine[2] //order by the date
select currLine
foreach(var line in dataLines)
Console.WriteLine(string.Join(" ",line))
I am not sure what you want to sort by or how you want to sort, so wasn't able to specify what you are looking for. The first method is the best because it establishes that the values should be sorted differently, otherwise you'd have to come up with your own sorting method for each field to sort them correctly without converting them to different objects.
List<T>, whereTis your class name. Then sort your list and turn it into an array.