reverse groups so they are drawn in the correct order