title: How to sort a vector using std::views C++20 feature?
body: <p>I want to loop through a vector in a sorted way <strong>without modifying the underlying vector</strong>.</p>
  <p>Can <code>std::views</code> and/or <code>std::range</code> be used for this purpose?</p>
  <p>I've successfully implemented filtering using <code>views</code>, but I don't know if it is possible to sort using a predicate.</p>
  <p>You can find an example to complete here : <a href="https://godbolt.org/z/cKer8frvq" rel="nofollow noreferrer">https://godbolt.org/z/cKer8frvq</a></p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ranges&gt;
  #include &lt;vector&gt;
  #include &lt;chrono&gt;
  
  struct Data{
      int a;
  };
  
  int main() {
  
      std::vector&lt;Data&gt; vec = {{1}, {2}, {3}, {10}, {5}, {6}};
    
      auto sortedView = // &lt;= can we use std::views here ?
                             
      for (const auto &amp;sortedData: sortedView) std::cout &lt;&lt; std::to_string(sortedData.a) &lt;&lt; std::endl; // 1 2 3 5 6 10
  
      for (const auto &amp;data: vec) std::cout &lt;&lt; std::to_string(data.a) &lt;&lt; std::endl; // 1 2 3 10 5 6
  }
  </code></pre>