Handle nil position values for sorting