fix sorting with null optional value