I have been learning about bubble sorting, binary trees, quick sort and a few other ways to to sort data using the Big O notation. While I wrote the code for a bubble sort I thought I would generate the worst case scenario. I inputed 100,000 values into a vector in descending order and sort them, and naturally outputted the values. It took 20 whole seconds to complete and I used the code I seen in the book.
However I decided to use the code I have always been using when I wanted to sort values.
then I would useCode:struct mySort { bool operator (int a, int b) {return a<b;} }Sort_Greater;
This was done in 2 seconds with the same vector with 1,000,000,000 values, I was blown away. What algorithm is sort using? I looked on cplusplus.com and it basically told me how to use it.Code:std::sort(myvector.begin,myvector.end,Sort_greater);
Is there more ways to sort out there as simple as this?