Makes it possible to sort over entity fields in list view.

Fix sorting by entity issue. See #1035