Try this python script: layer = iface.activeLayer() #Click layer in layer tree idfield = 'enum' #Change to match the name of your field' coords = [[f.geometry().asPoint().x(), f.geometry().asPoint().y(), f.id()] for f in layer.getFeatures()] #List x coordinate, y coordinate and id of each point coords.sort(key=lambda k: (k[1],-k[0]), reverse=True) #Sort by y, x order = [i[2] for i in coords] #Extract only the ids from the sorted list of lists i = layer.fields().indexFromName(idfield) attrMap = {id: {i:e} for e,id in enumerate(order,1)} layer.dataProvider().changeAttributeValues(attrMap) [![enter image description here][1]][1] [1]: https://i.sstatic.net/ozQ8y.png