Added sorting and sort direction