![](sad.gif)
Sorting an array of strings in Win32?
Im using FindFirstFile and FindNextFile to retrieve the contents of a folder but to my knowledge FindFirstFile doesnt sort them in alphabetical order
(unless there is a parameter I dont know about). Is there a Win32 function that will sort an array of strings in VC5 or 6? Or do I need to create my own sorting algorithm? Does FindFirstFileEx sort?
Thanks.
![](sad.gif)
Downloads: ZeroOne Realm
as far as I know you can use qsort. All you''ll need to do is write a small comparison function. One of the arguments to qsort will be a function pointer to your comparison function. I''m sure if you look up qsort in the docs you''ll find it.
kiev
kiev
Look around for info on the radix sort - if properly implemented, it''s far faster than the quicksort.
I don''t think there is a way of getting the files presorted using FindFirstFile() and FindNextFile(), but sorting using the STL is very simple.
If you are using a more complex structure to store your files, you can pass in an optional predicate function (that you write) to sort the files by date, time, size, or whatever else you want.
In the code above, YourFunctionObject refers to a functional object, which is a way of encapsulating a function inside an object. Any good STL book will explain all of this. Personally, I like "STL Tutorial and Reference Guide."
|
If you are using a more complex structure to store your files, you can pass in an optional predicate function (that you write) to sort the files by date, time, size, or whatever else you want.
|
In the code above, YourFunctionObject refers to a functional object, which is a way of encapsulating a function inside an object. Any good STL book will explain all of this. Personally, I like "STL Tutorial and Reference Guide."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement