Do you want to avoid problems with
math.nan? Then use #numpy!> np.sort([5., math.nan, 10., 0.])
array([ 0., 5., 10., nan])
> np.sort([math.nan, 1.])
array([ 1., nan])
> sorted([1., math.nan])
array([ 1., nan])
> np.max([3., math.nan, 1.])
nan
> np.nanmax([3., math.nan, 1.])
3.0