How do Ruby min and max compare strings?
<p>I'm playing around with iterators. What is Ruby comparing using <code>max</code> and <code>min</code>?</p>

<p>If I have this array: </p>

<pre><code>word_array = ["hi", "bob", "how's", "it", "going"]
</code></pre>

<p>and I run:</p>

<pre><code>puts word_array.max
puts word_array.min
</code></pre>

<p>I expect to get "going" or "how's" for <code>max</code>, since they're both five characters long, or "going" on the theory that it's the last item in the array. I expect <code>min</code> to return "hi" or "it", since they're tied for the shortest string. Instead, I get back:</p>

<pre><code>puts word_array.max -&gt; it
puts word_array.min -&gt; bob
</code></pre>

<p>What is Ruby measuring to make this judgement? It selected the shortest string for <code>max</code> and a middle length string for <code>min</code>.  </p>