group and order fields for viewdef