Added sorting to the array of the previous commit