any help? its a compile time error being triggered in a header file.
i have a vector of structs ...
Code:struct filestore { string filename; int wordcount; }; vector <filestore> filesortlist;
now i want to sort them by the wordcount value in desecending order
whats wrong with this
Code:std::sort(filesortlist.begin(), filesortlist.end());
any help? its a compile time error being triggered in a header file.
I have the experience that the header file is NEVER wrong (for some reason). Recheck any code relating to the header file, along with lines before it. What kind of error are you getting?
Rooted HTC Amaze 4G, Android 4.1.2 PA/AOKP/CM10 on teifin' AT&T's network; Rooted ASUS Transformer TF101 w/ dock, Android 4.0.3 Android Revolution HD; Laptop: HP HDX, 2.13GHzx2, 4GB, 128GB SSD, 1TB xHDD, Win7
Facebook page: Skeleville Software Solutions
Code:2472 C:\Dev-Cpp\include\c++\3.4.2\bits\stl_algo.h instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<filestore*, std::vector<filestore, std::allocator<filestore> > >, _Size = int]'
i dont think sort knows how to compare the elements of the vector/list.
you need to create a comparator or something like that.
a compare function, and either make it globally accessible or otherwise indicate that the sort routine should use it.
Cultured in Aggression and Koding like a Warrior!!
“Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
"The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein