From e29accb9cec5520d5fd923f573f161b06de155e0 Mon Sep 17 00:00:00 2001 From: dviid Date: Mon, 9 Apr 2012 13:35:16 +0200 Subject: [PATCH] fixed file ordering --- src/AbstractAnalysis.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 8ceb2c6..752f0ba 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -157,16 +157,29 @@ void AbstractAnalysis::create_dir_allocate_images() } +bool cmp_file(string f0, string f1) +{ + int v0 = atoi(f0.substr(0, f0.find("_")).c_str()); + int v1 = atoi(f1.substr(0, f1.find("_")).c_str()); + return v0 < v1; +} + void AbstractAnalysis::read_dir_create_list(string folder_path) { File dir(folder_path); if(dir.exists() && dir.isDirectory()) { vector list; - dir.list(list); + dir.list(list); + + std::sort(list.begin(), list.end(), cmp_file); + for(int i = 0; i < list.size(); i++) { string filepath = folder_path + "/" + list[i]; _saved_filenames_analysis.push_back(filepath); + + cout << list[i] << endl; + } } }