Hello There! I am *back*. I haven't been on this platform for quite a while now, but nothing has changed i see
So, I am making a CLI Terminal project in C++ (full code at https://www.github.com/PCPPTech/-F00L.)
```
for(const string& element : folders_withDot)
inorder.push_back(element);
for(const string& element : folders)
inorder.push_back(element);
for(const string& element : files_withDot)
inorder.push_back(element);
for(const string& element : files)
inorder.push_back(element);
```
here, I iterate thru all the previous string vectors
Here is the code before that:
```
vector<string> folders_withDot, folders, files_withDot, files, inorder; // creating every list where we will store certain stuff in 1 line
for(const auto& entry : fs::directory_iterator(path)) { // iterate thru the given path
string filename = entry.path().filename().string(); // This is our readable filename
// first = Folders starting with .
if (filename.starts_with(".") && fs::is_directory(entry.path())) // if it starts with a dot and is a directory
folders_withDot.push_back(filename); // then it belongs in the folder_withDot string vector.
// second = Ordinary Folders (not starting with .)
if (fs::is_directory(entry.path()) && !(filename.starts_with("."))) // if it is a directory and it doesn't start with a dot
folders.push_back(filename); // then it belongs in the normal folders string vector
// third = Files starting with a .
if (!(fs::is_directory(entry.path())) && filename.starts_with(".")) // if it isn't a directory but does start with a dot
files_withDot.push_back(filename); // then it belongs in the files_withDot string vector
// fourth = files that dont start with a dot.
if (!(fs::is_directory(entry.path())) && !(filename.starts_with("."))) // if it isn't a directory and it doesnt start with a dot
files.push_back(filename); // then it belongs in the normal files string vector.
// iterate thru each one... this is gonna be so so so slow...
// idk how to iterate thru 4 arrays in 1 for loop without knowing their length for sure
}
```
I tried to comment everything thoroughly.
So I iterated thru all the sorted string vectors and put them inorder in the string vector `inorder`.
So, my problem is that the first code i provided is really repetitive and I think there is a better way to do it. Maybe nested loops? I dont know.
If you have an idea, Please share it here, I appreciate it! ^^