Fix reordering of conf sections and groups

Fixes #1749