I have the following code:
int main()
{
int intArr[] = { 1,5,3 };
//auto f = [](auto a, auto b) {return a < b;};
//std::sort(intArr, intArr + 2, f);
std::sort(intArr, intArr + 2);
for (int& temp : intArr)
cout << temp << endl;
}
However, the output is unsorted (e.g. the output is 1 5 3
). The same result when using std::sort
with lambda. What is causing this behavior?
I am using Visual C++ compiler (Visual Studio 2015).