title: error: ‘class std::vector<Shape*>’ has no member named ‘sort’
body: <p>I have a code where I am drawing different Shape , now there can be preference on which one to draw first among say Square, rectangle and triangle . I have override the "&lt;" ( less than operator for base class Shape. My preference of drawing is in increasing order as mentioned in typeOrderTable. Therefore triangle will be drawn before Square But upon compilation I get the error error: ‘class std::vector’ has no member named ‘sort’. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;typeinfo&gt;
  #include &lt;string.h&gt;
  using namespace std;
  
  
  class Shape 
  { 
      public: 
      virtual void Draw() const = 0; 
      virtual bool Precedes(const Shape&amp;) const ;
      bool operator&lt;(const Shape&amp; s) 
      {
          return Precedes(s);
      }
      private:    
      static char* typeOrderTable[];
  };
  
  char* Shape::typeOrderTable[] = {"Rectangle","Square","Triangle",0 };
  
  bool Shape::Precedes(const Shape&amp; s) const 
  {
      const char* thisType = typeid(*this).name();    
      const char* argType = typeid(s).name();    
      bool done = false;    int thisOrd = -1;    
      int argOrd = -1;    
      for (int i=0; !done; i++)    
      {        
          const char* tableEntry = typeOrderTable[i];
          if (tableEntry != 0)        
          {            
              if (strcmp(tableEntry, thisType) == 0)                
              thisOrd = i;            
              if (strcmp(tableEntry, argType) == 0)                
              argOrd = i;
              if ((argOrd &gt; 0) &amp;&amp; (thisOrd &gt; 0))                
              done = true;        
  
          }        
          else // table entry == 0            
          done = true;    
      }    
      return thisOrd &lt; argOrd; 
  }
  
  class Square : public Shape 
  { 
      public: 
      virtual void Draw() const 
      { 
          std::cout &lt;&lt; "Inside Draw of Square \n" ; 
  
      } 
  };
  
  class Rectangle : public Shape 
  { 
      public: 
      virtual void Draw() const 
      { 
          std::cout &lt;&lt; "Inside Draw of Rectangle \n" ; 
  
      } 
  };
  
  class Triangle : public Shape 
  { 
      public: 
      virtual void Draw() const 
      { 
          std::cout &lt;&lt; "Inside Draw of Triangle \n" ; 
  
      } 
  };
  
  void DrawAllShapes(std::vector&lt;Shape*&gt;&amp; list) 
  {        
      std::vector&lt;Shape*&gt; orderedList = list;
      orderedList.sort();    
      std::vector&lt;Shape*&gt;::iterator it =orderedList.begin();
      for (;it!=orderedList.end(); ++it)
      (*it)-&gt;Draw(); 
  }
  
  int main() 
  {
  std::vector&lt;Shape*&gt; vec;
  vec.push_back(new Triangle);
  vec.push_back(new Square);
  vec.push_back(new Rectangle);
  vec.push_back(new Square);
  DrawAllShapes(vec);
  return 0;
  }
  </code></pre>