back

by AlexeyBrin·11y ago·view on hn ↗
Let's try again, with a more C++14 like solution:

     sort(v.begin(),v.end(),[](const auto x, const auto y) { return *x > *y; });
instead of your line 39:

     sort(v.begin(),v.end(),[](const string *x, const string *y) { return *x > *y; });
Some results:

• g++ 4.9.2 with O3 qsort 545ms, sort 7289ms

• clang with O3 and libc++ qsort 551ms, sort 844ms

I've used:

   clang++ -std=c++1y -stdlib=libc++ -O3 test.cpp
and

    g++-4.9.2 -std=c++14 -O3 test.cpp
1 comments
The first is comparing pointers, not strings. I wouldn't call this a fair comparison.
+1 I stand corrected.

I've updated my tests and qsort seems to be faster than sort, for this particular test case.