Preserve the region order when flushing a RegionSet

Related to limetext/lime#341.
My fuzzy mind has had some trouble getting this refactor working. I might revisit it when my brain feels fresher, but feel free to have a go.