0

it might be some logic issue, but can't figure out

how can I sort my files where prefix_100.png is greater than prefix_2.png ?

thanks

        var filesRaw = Directory.GetFiles(path, "*.png").Select(fn => new FileInfo(fn)).
                                OrderBy(f => f.Name).ToList();
RollRoll
  • 8,133
  • 20
  • 76
  • 135
  • it may help if the filenames had leading zeros like `prefix_002.png` – RadioSpace Oct 14 '14 at 23:35
  • 1
    Right justify the numeric portion: `prefix_002.png`. Either rename the files or extract the numeric portion and right-justify it while you're sorting. –  Oct 14 '14 at 23:35
  • [Padding msdn](http://msdn.microsoft.com/en-us/library/66f6d830(v=vs.110).aspx) – RadioSpace Oct 14 '14 at 23:37
  • Search term "natural sort" - make sure to check other answers (i.e. http://stackoverflow.com/questions/248603/natural-sort-order-in-c-sharp) if you find duplicate did not cover all possibilities. – Alexei Levenkov Oct 14 '14 at 23:43

0 Answers0