Fix for logical sorting.