Daniel James wrote:
Surya Kiran Gullapalli wrote:
The best way should be to use bind (or am i wrong here ?) from Boost library.
But i'm not getting the syntax correctly here.
the crude way could be
*stable_sort (files.begin(), files.end(), (bind (&File::get_size, _1)
bind (&File::get_size, _2))) ;*
that is call get_size() on first argument, and call get_size() on second argument, and compare those values, and return a boolean value.
Can anybody please help me out with the syntax here. ??
Right syntax, wrong library. You can do this with Boost.Lamba. [snip]
Or if you really want to use Boost.Bind, something like: using namespace boost; stable_sort(files.begin(), files.end(), (bind(std::greater<int>(), bind(&File::get_size, _1), bind(&File::get_size, _2)))) ; Remembering to include <functional> to get std::greater. Daniel