Added sorting of the lists to the main splitting algorithm