diff --git a/C++/SortingWithComparator.cpp b/C++/SortingWithComparator.cpp new file mode 100644 index 0000000..b1a7af0 --- /dev/null +++ b/C++/SortingWithComparator.cpp @@ -0,0 +1,11 @@ +#include +using namespace std; +bool compare(int a, int b){ + return a > b; +} +vector sortingWithComparator(vector v, bool flag){ + // your code goes here + if(flag) sort(v.begin(), v.end()); + else sort(v.begin(), v.end(), compare); + return v; +} \ No newline at end of file