alphabetical sort
Change-Id: I4b1bb6787a5cbe1e99e3d8b0cc5bf37d7167398d
This commit is contained in:
parent
0837091e8d
commit
1e8aabad34
@ -214,6 +214,21 @@ char** gather_files(const char* directory, const char* fileExtensionOrDirectory,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// sort the result
|
||||
if (files != NULL) {
|
||||
for (i = 0; i < total; i++) {
|
||||
int curMax = -1;
|
||||
int j;
|
||||
for (j = 0; j < total - i; j++) {
|
||||
if (curMax == -1 || strcmp(files[curMax], files[j]) < 0)
|
||||
curMax = j;
|
||||
}
|
||||
char* temp = files[curMax];
|
||||
files[curMax] = files[total - i - 1];
|
||||
files[total - i - 1] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user