diff --git a/src/filesrch.c b/src/filesrch.c
index 944e8447f4d462c5ee7cac302a7481422e184613..7ccf532c8a750e0b5fbe337b869b1e10fb86def2 100644
--- a/src/filesrch.c
+++ b/src/filesrch.c
@@ -699,6 +699,13 @@ static void initdirpath(char *dirpath, size_t *dirpathindex, int depthleft)
 		dirpathindex[depthleft]--;
 }
 
+//sortdir by name? 
+static int lumpnamecompare( const void *A, const void *B )
+{
+	return strcmp( (((lumpinfo_t *)A)->fullname), (((lumpinfo_t *)B)->fullname));
+
+}
+
 lumpinfo_t *getdirectoryfiles(const char *path, UINT16 *nlmp, UINT16 *nfolders)
 {
 	DIR **dirhandle;
@@ -889,6 +896,9 @@ lumpinfo_t *getdirectoryfiles(const char *path, UINT16 *nlmp, UINT16 *nfolders)
 	free(dirpathindex);
 	free(dirhandle);
 
+	//sort files and directories
+	qsort ( lumpinfo, numlumps, sizeof( lumpinfo_t ), lumpnamecompare );
+
 	(*nlmp) = numlumps;
 	return lumpinfo;
 }