Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
two lists, sorted and original, merged solution in Clear category for Sort Except Zero by kkkkk
from typing import Iterable
def except_zero(items: list) -> Iterable:
"""Return sorted items, but leave zeros in their position."""
sorted_items = [item for item in sorted(items) if item != 0]
for idx, item in enumerate(items):
if item:
items[idx] = sorted_items.pop(0)
return items
Feb. 29, 2020
Comments: