namespace "std" has no member "sort"

43,559

Add:

#include <algorithm>

as stated in the std::sort() reference page.

See Using std Namespace, Why is "using namespace std" considered bad practice? and many other questions on SO discussing using namespace std;.

Share:
43,559
Admin
Author by

Admin

Updated on October 25, 2020

Comments

  • Admin
    Admin over 3 years

    Trying to sort an array of Integers and after some googling, came across the solution using std::sort accompanied by this error: namespace "std" has no member "sort".

    Just to disqalify any qualms that I'm not using the std namespace, here is my header:

    #include "stdafx.h"
    #include <iostream>
    #include <fstream>
    #include <sstream>
    #include <string>
    using namespace std;
    
  • Cory Trese
    Cory Trese almost 8 years
    This resolved my error namespace "std" has no member "sort" while attempting to compile with gnustl_static on the Android NDK. The reference to std::sort works in XCode and Visual Studio, but for the NDK I needed to add the include from this answer. Thanks!