# Reorder forum groups

To reorder forum groups, you must perform the following:

1. Change the ordinal of the specified group.\
   Query the specified group and modify the value of its `Ordinal` property. For more information, see [For developers: Modify forum groups](https://www.progress.com/documentation/sitefinity-cms/for-developers-modify-forum-groups).
2. Update the ordinals of the other groups.\
   Update the values of the `Ordinal` properties of the other groups according to the new ordinal of the specified group.

Here is a code example:

```C#
using System;
using System.Linq;
using Telerik.Sitefinity.Forums;

namespace SitefinityWebApp
{
    public class ReorderForumGroups_MoveForumGroup
    {
        public static void MoveForumGroup(Guid groupId, int newOrdinal)
        {
            ForumsManager forumsManager = ForumsManager.GetManager();

            var forumGroup = forumsManager.GetGroup(groupId);

            //Validate new position
            if (newOrdinal < 0 || newOrdinal == forumGroup.Ordinal)
            {
                return;
            }
            else if (newOrdinal > forumsManager.GetGroups().Count())
            {
                newOrdinal = forumsManager.GetGroups().Count();
            }

            //Preserve the old ordinal value
            var oldOrdinal = forumGroup.Ordinal;

            //Assign the new ordinal value
            forumGroup.Ordinal = newOrdinal;

            //Reorder the other groups.
            foreach (var group in forumsManager.GetGroups())
            {
                if (group.Equals(forumGroup))
                {
                    continue;
                }

                //Moving up
                if (newOrdinal < oldOrdinal)
                {
                    //Update only the items between the new and the old position
                    if (group.Ordinal >= newOrdinal && group.Ordinal < oldOrdinal)
                    {
                        group.Ordinal++;
                    }
                }
                //Moving down
                else
                {
                    //Update only the items between the new and the old position
                    if (group.Ordinal <= newOrdinal && group.Ordinal > oldOrdinal)
                    {
                        group.Ordinal--;
                    }
                }
            }

            forumsManager.SaveChanges();
        }
    }
}
```
