The problem seems to have been caused when I had three different variants with duplicate sort orders. When I adjusted the sort orders to all be unique, the problem went away. When I now try to reintroduce the error by creating duplicates with existing variants, I don't get the error.
Perhaps it's with duplicates when they are first added? I don't know. It happened again this morning before I removed the duplicates.