Added sorting method for output