Sort by level correctly