Sorting with nil

Fix sorting when nil is present as a value. Set whether a filter should be used in grouping and sorting.