How to sort null field values in Drupal? I have a content type with one field of type text.

I add content for 5 nodes.

For 2 nodes among 5, I entered nothing in text-field.

So scenario is 3 nodes have data in that field and 2 of the nodes are empty.

Now I'm sorting on behalf of that particular text-field in my custom module and the result is:

It hides node with empty content.

It means only 3 nodes are visible, empty values are not visible.

Expected result should be, the fields that don't have any value inside should also get sorted and the resulting nodes would be seen either at the top of all sort-able content or below it.

How can I achieve this?
You can achieve it by installing Views Sort Null Field module.


  This module provides an additional sort for FieldAPI fields, which
  sorts by whether the field is empty or not. This allows empty (i.e.
  NULL) values in fields to be sorted last.