title: Ruby sort_by for arrays returned by MySQL, date formatted as string
body: <p>I have a database that has a <code>task</code> table.  In that table, there is a <code>date</code> column.  Those dates are formatted as strings, they aren't <code>Date</code>.</p>
  
  <p>I'm trying to sort these tasks by date.  I already have an array of the tasks named <code>tasks</code>. I'm trying to replace it with the sorted array called <code>tasksByDate</code> using the below code.</p>
  
  <pre><code>tasksByDate = tasks.sort_by do |task|
    task[:date].to_date
  end
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>TypeError: no implicit conversion of Symbol into Integer
  </code></pre>
  
  <p>I also tried without <code>to_date</code> just to see if it would sort it without it being  a date, and just being a string.</p>
  
  <p>The <code>date</code> field is formatted as a string like so <code>2016-08-29</code>.  I used the <code>to_date</code> method on it somewhere else in the code, and it works great, so I didn't really think that was the problem.  </p>
  
  <hr>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I have checked that tasks actually contains a date, and it is formatted like explained.  </p>
  
  <p>The output of <code>p task.class</code> is <code>Array</code></p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>The output of <code>p task</code> is</p>
  
  <pre><code>[#&lt;User id: 10, login: "my.name", hashed_password: "", date: "2016-08-29"&gt;]
  </code></pre>