Fix NULL sort bug