Values changed with Editor Script don't get saved

I have a simple editor script that alters the sortingOrder property of the SpriteRenderer of my GameObjects (which are mostly instantiated prefabs).
It all works fine, however, after I saved my project and reopen it, it reverts all values back to what they were before I altered them.

Why is that and how can I make it persist?

    if(GUILayout.Button("Fix Z-Order")) {
        GameObject group = GameObject.Find("Doodads");
        if(group == null)
            Debug.LogError("GameObject not found!");
        SpriteRenderer[] srs = group.GetComponentsInChildren<SpriteRenderer>();
        foreach(SpriteRenderer r in srs) {
            float y = r.transform.position.y;
            r.sortingOrder = -(int)(y * 100);
        }
    }

Nevermind, I found the solution:
For some reason, it is nowhere stated that you have to call UnityEditor.SetDirty(object) after you modified object’s value!