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 most simple solution for me is
def sorted_children(children) children.sort_by { |child| child.position || -1} end