Tuesday, July 30, 2013

Sorting filenames...please help!

Here is another possible solution:



static void Main(string[] args) {
string path = <yourFilePath>;
string pattern = "(?<=.{10})\\w{4}(?=.*)";

var result = File.ReadLines(path).OrderBy(x => Regex.Match(x, pattern).Value);

foreach (var item in result) {
Console.WriteLine(item);
}

Console.ReadKey();
}


wizend

No comments:

Post a Comment