title: Sorting strings with numerical digits in it
body: <p>I have strings like <code>7X1234 XY1236 NM1235</code>. I want to sort this strings using last 4 numerical digits only ignoring the initial two alphabets. Also, I want to compare those numerical digits to see if they are sequential. </p>
  
  <p>One way to achieve this I can think of is to split these strings between alphabets and numerals as (<code>7X and 1234</code>) and work lexical cast the numeral string to int and work on it. But, how can I associate the alphabet part again to the numeral part that is how to prefix <code>7X</code> again to <code>1234</code> at the end when the numeral strings are sorted and compared in <code>C++</code>?</p>
  
  <p>In short if I have <code>7X1234 XY1236 NM1235 BV1238</code> I need to get <code>7X1234 NM1235 XY1236 BV1238</code> </p>
  
  <p>I did not elaborate that I wanted to find out if the numerical part of strings are sequential. Right now when I have just ints like 1234 1236 1235 1238 I do something like below</p>
  
  <pre><code>            std::vector&lt;int&gt; sortedDigits{1234 1235 1236 1238};
              int count = 1;
              int pos = 0;
              std::vector&lt;std::pair&lt;int, int&gt; &gt; myVec;
              myVec.push_back(std::make_pair(sortedDigits[pos], count));
              for(size_t i = 1; i &lt; sortedDigits.size(); ++i)
              {
                  if(sortedDigits[i] != (sortedDigits[i-1] + 1))
                  {
                     count = 1;
                     myVec.push_back(std::make_pair(sortedDigits[i], count) );
                     ++pos;
                  }
                  else
                  {
                      sortedDigits[pos].second = ++count;
                  }
              }  
  </code></pre>
  
  <p>So at the end I get <code>(1234, 3)</code> and <code>(1238, 1)</code></p>
  
  <p>I don't know how can I get something like this when strings are there? </p>