title: sort ruby array by numbers
body: <p>I have a few hundred images in an S3 bucket which I write into an array and want them being sorted and displayed alphabetically. The images all start with the same pattern</p>
  
  <pre><code>#1 &lt;some name&gt;.jpg
  #2 &lt;some name&gt;.jpg
  ...
  #10 &lt;some name&gt;.jpg
  #11 &lt;some name&gt;.jpg
  ...
  </code></pre>
  
  <p>after using</p>
  
  <pre><code>@images.each do |image|
  @image[i] = image.url_for(:read).to_s
      i = i + 1
  end
  
  @image.sort
  </code></pre>
  
  <p>however, the @image array is being sorted this way:</p>
  
  <pre><code>&lt;s3 bucket URL&gt;/#1 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#10 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#11 &lt;some name&gt;.jpg
  ...
  &lt;s3 bucket URL&gt;/#2 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#20 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#21 &lt;some name&gt;.jpg
  ...
  </code></pre>
  
  <p>It is my understanding that the "alphabet" and therefore the sorting should sort #1, #2, #3 etc. but that does not seem to be the case.
  Obviously, I want it being sorted this way:</p>
  
  <pre><code>&lt;s3 bucket URL&gt;/#1 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#2 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#3 &lt;some name&gt;.jpg
  ...
  &lt;s3 bucket URL&gt;/#10 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#11 &lt;some name&gt;.jpg
  &lt;s3 bucket URL&gt;/#12 &lt;some name&gt;.jpg
  ...
  </code></pre>
  
  <p>How could I reach this with a sort algorithm in this case?
  Thanks for any help.</p>