"python/scipy: find ""bounded"" min/max of a matrix","b = np.sort(a[..., :-1], axis=-1)"