1. A method for data storage, comprising: predefining an order of programming a plurality of analog memory cells that are arranged in rows, wherein the memory cells in each row are associated with a respective word line, and wherein each memory cell is programmable to assume programming levels corresponding to respective analog values written to the memory cell, wherein the order specifies that for a given row having neighboring rows on first and second sides, the memory cells in the given row are programmed only while the memory cells in the neighboring rows on at least one of the sides are in an erased state, and that the memory cells in the given row are programmed to assume one or more highest programming levels, which correspond to respective largest analog values among the analog values, only after programming all the memory cells in the given row to assume the programming levels other than the highest levels; and storing data in the memory cells by programming the memory cells in accordance with the predefined order.