private static void SortEnumMembers(ISolution solution, IEnumDeclaration enumDeclaration,
                                     CSharpElementFactory factory)
 {
     try {
         var enumMembers = new SortedDictionary<string, IEnumMemberDeclaration>();
         foreach (IEnumMemberDeclaration enumMember in enumDeclaration.EnumMemberDeclarations) {
             enumMembers.Add(enumMember.DeclaredName, enumMember);
         }
         IEnumMemberDeclaration firstEnumMember = null;
         foreach (IEnumMemberDeclaration enumMember in enumMembers.Values) {
             firstEnumMember = enumMember;
             break;
         }
         foreach (IEnumMemberDeclaration enumMember in enumMembers.Values) {
             if (enumMember != firstEnumMember) {
                 enumDeclaration.RemoveEnumMemberDeclaration(enumMember);
             }
         }
         IEnumMemberDeclaration lastEnumMember = enumDeclaration.EnumMemberDeclarations[0];
         foreach (IEnumMemberDeclaration enumMember in enumMembers.Values) {
             if (enumMember != firstEnumMember) {
                 IEnumMemberDeclaration newMember = factory.CreateEnumMemberDeclaration(enumMember.DeclaredName);
                 newMember.SetValueExpression(enumMember.ValueExpression);
                 lastEnumMember = enumDeclaration.AddEnumMemberDeclarationAfter(newMember, lastEnumMember);
             }
         }
     }
     catch (Exception err) {
         Exception e = err;
     }
 }