title: sorting a ruby array of objects by an attribute that could be nil
body: <p>I have an array of objects that I need to sort by a position attribute that could be an integer or nil, and I need the objects that have the nil position to be at the end of the array. Now, I can force the position to return some value rather than nil so that the array.sort doesn't fail, but if I use 0 as this default, then it puts those objects at the front of the sort. What's the best way to to do this sort? should I just set the nil values to some ridiculously high number that is 'almost' always guaranteed to be at the end? or is there some other way i could cause the array.sort method to put the nil attribute objects at the end of the array? the code looks like this: </p>
  
  <pre><code>class Parent
    def sorted_children
       children.sort{|a, b| a.position &lt;=&gt; b.position}
    end
  end
  
  class Child
    def position
      category ? category.position : #what should the else be??
    end
  end
  </code></pre>
  
  <p>now, if i make the 'else' something like 1000000000, then it's most likely gonna put them at the end of the array, but I don't like this solution as it's arbitrary</p>