Rewrite sort_rooms() to handle lev->doorindex == 0

This replaces the variable length stack arrays and inner function of the
former implementation.  This should hopefully fix level generation for
OS X builds (issue #70).