Click here to Skip to main content
15,914,452 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Difficult to sort Pin
Amarnath S12-Feb-15 0:08
professionalAmarnath S12-Feb-15 0:08 
GeneralRe: Difficult to sort Pin
Garth J Lancaster11-Feb-15 22:50
professionalGarth J Lancaster11-Feb-15 22:50 
GeneralRe: Difficult to sort Pin
Mike Hankey11-Feb-15 23:09
mveMike Hankey11-Feb-15 23:09 
GeneralRe: Difficult to sort Pin
_Maxxx_12-Feb-15 0:51
professional_Maxxx_12-Feb-15 0:51 
GeneralRe: Difficult to sort Pin
Mark_Wallace11-Feb-15 23:16
Mark_Wallace11-Feb-15 23:16 
GeneralRe: Difficult to sort Pin
Johnny J.11-Feb-15 23:20
professionalJohnny J.11-Feb-15 23:20 
GeneralRe: Difficult to sort Pin
FIorian Schneidereit12-Feb-15 0:29
FIorian Schneidereit12-Feb-15 0:29 
GeneralRe: Difficult to sort : SOLVED!! Pin
newton.saber12-Feb-15 2:08
newton.saber12-Feb-15 2:08 
Here, I solved this with C# and Linqpad.
Here are the steps:
1. Get LINQPad at http://www.linqpad.net/[^]
It's a great free tool which allows you to run C# as a script

2. Copy the code below to LINQPad
3. Change the <yourPathToFiles> to the path to your files.
4. run

Notice that it uses an enumeration to set the value automatically of each string ("first", "second", etc) to a numeric value.
After that it adds the file names to the SortedList and then prints them out.
Easy as that.

If you need other FileInfo about those files, it would be very easy to add. This'll get you started.
The number one thing about this is, GET LINQPAD. It is a great tool.

void Main()
{
	string [] allFiles = Directory.GetFiles(@"C:\<yourPathToFiles>","*.txt");
	SortedList allFileNames = new SortedList();
	order fileSortOrder = new order();
	foreach (string filename in allFiles)
	{
		string tempName = Path.GetFileNameWithoutExtension(filename);
		allFileNames.Add(Enum.Parse(fileSortOrder.GetType(),tempName), Path.GetFileName(filename));
	}
	for (int i=0; i< allFileNames.Count;i++)
	{
		Console.WriteLine(allFileNames.GetByIndex(i));
	}
}

enum order
{
	first,
	second,
	third,
	fourth,
	fifth,
	sixth,
	seventh,
	eighth,
	ninth,
	tenth,
	eleventh
}



OUTPUT
VB
first.txt
second.txt
third.txt
fourth.txt
fifth.txt
sixth.txt
seventh.txt
eighth.txt
ninth.txt
tenth.txt
eleventh.txt

GeneralRe: Difficult to sort : SOLVED!! Pin
#realJSOP12-Feb-15 2:11
professional#realJSOP12-Feb-15 2:11 
GeneralRe: Difficult to sort : SOLVED!! Pin
newton.saber12-Feb-15 2:16
newton.saber12-Feb-15 2:16 
GeneralRe: Difficult to sort : SOLVED!! Pin
Freak3012-Feb-15 2:29
Freak3012-Feb-15 2:29 
GeneralRe: Difficult to sort : SOLVED!! Pin
newton.saber12-Feb-15 2:30
newton.saber12-Feb-15 2:30 
GeneralRe: Difficult to sort : SOLVED!! Pin
PIEBALDconsult12-Feb-15 4:00
mvePIEBALDconsult12-Feb-15 4:00 
GeneralRe: Difficult to sort : SOLVED!! Pin
Kenneth Haugland12-Feb-15 4:51
mvaKenneth Haugland12-Feb-15 4:51 
GeneralRe: Difficult to sort : SOLVED!! Pin
Amarnath S12-Feb-15 2:30
professionalAmarnath S12-Feb-15 2:30 
GeneralRe: Difficult to sort : SOLVED!! Pin
PhilLenoir12-Feb-15 2:50
professionalPhilLenoir12-Feb-15 2:50 
GeneralRe: Difficult to sort : SOLVED!! Pin
newton.saber12-Feb-15 2:54
newton.saber12-Feb-15 2:54 
GeneralRe: Difficult to sort : SOLVED!! Pin
PhilLenoir12-Feb-15 2:58
professionalPhilLenoir12-Feb-15 2:58 
GeneralRe: Difficult to sort : SOLVED!! Pin
newton.saber12-Feb-15 3:14
newton.saber12-Feb-15 3:14 
GeneralRe: Difficult to sort : SOLVED!! Pin
PhilLenoir12-Feb-15 3:15
professionalPhilLenoir12-Feb-15 3:15 
GeneralRe: Difficult to sort Pin
BillWoodruff12-Feb-15 3:42
professionalBillWoodruff12-Feb-15 3:42 
GeneralRe: Difficult to sort Pin
Amarnath S12-Feb-15 3:46
professionalAmarnath S12-Feb-15 3:46 
GeneralRe: Difficult to sort Pin
BillWoodruff12-Feb-15 4:01
professionalBillWoodruff12-Feb-15 4:01 
GeneralRe: Difficult to sort Pin
#realJSOP12-Feb-15 4:29
professional#realJSOP12-Feb-15 4:29 
GeneralRe: Difficult to sort Pin
Kenneth Haugland12-Feb-15 6:30
mvaKenneth Haugland12-Feb-15 6:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.