Add group ordering support

Make sure groups can be properly ordered in the UI according to their weight (descending).