Added support for sorting and preferences to choose sort by value.