Fixed array sorting issues (no longer pushing all els with children to the bottom)

Thanks to an awesome job by Nicofuma