Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
sort nonzero, and replace nonzero solution in Speedy category for Sort Except Zero by PythonWithPI
from typing import Iterable
def except_zero(items: list) -> Iterable:
sorted_iterator = iter(sorted(filter(None, items)))
return (next(sorted_iterator) if item else 0 for item in items)
Feb. 20, 2020
Comments: