title: Sorting a structure vector by a value within the struct
body: <p>First of all, I would like to thank you for the assistance. I am attempting to sort a vector of structs by a value within the struct, which in this case is an double. The struct looks like this.</p>
  
  <pre><code>struct countryInfoStruct
  {
      int countryNumber;
      double latitude;
      double longitude;
      string city;
      string country;
      double distance;
  };
  </code></pre>
  
  <p>My vector name is:</p>
  
  <pre><code>vector&lt;countryInfoStruct&gt; countries;
  </code></pre>
  
  <p>Which is populated by a .csv file, which works correctly. My problem is sorting. I created a function that is intended to sort the vector; however, something is missing. The error that I am getting is </p>
  
  <blockquote>
    <p>CountryData::countryInfoStruct incomplete type is not allowed</p>
  </blockquote>
  
  <p>I have researched this many times, but have not been able to fix it. The error message is underlining "<code>countryInfoStruct</code>". Below is my <code>sortVector</code> Function.</p>
  
  <pre><code>void CountryData::sortVector()
  {
      CountryData m;
      auto sortFunc = [](countryInfoStruct a, countryInfoStruct b) -&gt; bool {
          return a.distance &lt; b.distance;
  }
  </code></pre>
  
  <p>Of note: I know that I am missing the iterator below, but this is because I have not been able to get the actual function to work.</p>
  
  <pre><code>sort(countries.begin(), countries.end(), sortVector); 
  </code></pre>