title: Reorder a vector based on the pattern of another in R?
body: <p>I have a vector <code>nhs_regions</code>. I add the suffix <em>&quot;.upper&quot;</em> and <em>&quot;.lower&quot;</em> to every element of <code>nhs_region</code> in <code>y</code>.
  I now need to reorder the vector <code>y</code> as per the <code>nhs_regions</code> vector. So I expect the final vector to start with <em>&quot;England.upper&quot;, &quot;England.lower&quot;, &quot;East of England.upper&quot;, &quot;East of england.lower&quot;</em> etc...<br />
  Example below:</p>
  <pre><code>nhs_regions &lt;- c(&quot;England&quot;,&quot;East of England&quot;,&quot;London&quot;,&quot;Midlands&quot;,&quot;North East and Yorkshire&quot;,&quot;North West&quot;,&quot;South East&quot;,&quot;South West&quot;)
  x &lt;- c(&quot;lower&quot;, &quot;upper&quot;)
  y &lt;- as.vector(outer(nhs_regions, x, paste, sep=&quot;.&quot;))
  </code></pre>