title: Sort an array depending on given set of characters within each element
body: <p>I have an array made of a number of elements read from a .txt file. Each element is long and has a lot of information, for instance:
  <code>20201102066000000000000000000000000020052IC04008409Z8000000000030546676591AFIP</code></p>
  <p>All the lines are already part of the array <code>lines_array</code>, but I need to sort them out depending on the content of the 36° character until the 51°, which in the example provided above would be:
  <code>20052IC04008409Z</code></p>
  <p>I was already able to catch the patterns from each of the elements in the array:</p>
  <pre><code>    lines_array = File.readlines(complete_filename)
  
      pattern = nil
      lines_array.each do |line|
      pattern = line[36] + line[37] + line[38] + line[39] + line[40] + line[41] + line[42] + line[43] + 
      line[44] + line[45] + line[46] + line[47] + line[48] + line[49] + line[50] + line[51]
      end
  </code></pre>
  <p>What I need to do now is to be able to sort <strong>alphabetically</strong> all the elements of the array (with the long elements) based on the content of the variable variable <code>pattern</code>. I tried with methods <code>sort</code> and <code>sort_by</code> but I wasn't able to pass my variable <code>pattern</code> as a parameter. For example, a correct order of three given elements would be:</p>
  <p><code>20201102066000000000000000000000000020001IC04180127X8000000000030546676591AFIP</code>
  <code>20201104066000000000000000000000000020001IC04182757T8000000000030546676591AFIP</code>
  <code>20201102066000000000000000000000000020001IC05020641D8000000000030546676591AFIP</code></p>
  <p>Any help?</p>