Extract sort fields from conditional block.
Add tagging support.
Add missing import.