DOCS-974 and DOCS-1105 agg min and null values and agg sort and optimizations