MongoDB sort by only exists entry, key with value first and key with null or not exists last
I used a dirty hack for this.
MongoDB doc says that they have priorities for sorting as posted below image.
So when i sort with asc then it sort first all null (empty key consider as null) entries then sort numeric entries.
What is hack here ?
Store sr_no : ""
with empty string default.
Now it will sort first numeric values then string.