• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mongodb sorting null last for ascending order

 
Kishan Godishala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am facing one issue while using the mongodb sorting. By default sorting takes place on null values as first elements for ascending order and last elements in descending order. For one of my requirement i have to display all null values at last place irrespective of the sorting order.

If it is single column, it should be fine. But i have to sort on multiple fields at a time. And for all the fields it has to take consider all null values as last values.

Is there any way that mongodb supports for this. I am using spring data. Thought spring sort provides the feature of Null Last as the parameter, some how it is not working.

It is very urgent for me. I really appreciate if any one help me on this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic