Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

array List Sorting according to the file extension

Tags:

c#

arraylist

i am having some file names in array list Like, "Form.frm,Form1.frm,Form2.frm,Module.bas,Module23.bas" in the array list i want to make the first item as ".bas" files how can i make it using array list.

like image 951
tgranjith Avatar asked Nov 22 '25 01:11

tgranjith


1 Answers

First i would suggest to use the strongly typed List<T> instead. You can use Path.GetExtension and Linq's Enumerable.OrderBy:

List<String> files = new List<String>(){ "Form2.frm","Module.bas","Module23.bas" };
var ordered = files.OrderBy(fn => Path.GetExtension(fn));
like image 73
Tim Schmelter Avatar answered Nov 23 '25 15:11

Tim Schmelter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!