Q: Serialization xml : 2 lists mixed up I'm currently running into a problem with xml serialization in C#.
I have a XML structure like this in my programm that represent a tree :
<FlatNodeTree>
  <Node>
    <Level>1</Level>
    <Name>Element 0</Name>
    <Guid>AAA</Guid>
    <NodeType>XElt</NodeType>
    <GuidParent />
  </Node>
  <Node>
    <Level>1</Level>
    <Name>Block 1</Name>
    <Guid>BBB</Guid>
    <NodeType>XBlock</NodeType>
    <GuidParent />
  </Node>
  <Node>
    <Level>2</Level>
    <Name>Element 1</Name>
    <Guid>CCC</Guid>
    <NodeType>XElt</NodeType>
    <GuidParent>BBB</GuidParent>
  </Node>
  <Node>
    <Level>1</Level>
    <Name>Element 2</Name>
    <Guid>DDD</Guid>
    <NodeType>XElt</NodeType>
    <GuidParent />
  </Node>
</FlatNodeTree>

As ou can see there are nodes (XBlock) and leafs (XElt), and and object of level > 1 is attached to a parent node by Guid.
I want it to be saved in an xml structure like this (it's very simplified, but you get the idea):
<Article>
    <Elt>Element 0</Elt>
    <Block name='Block 1'>
        <Elt>Element 1</Elt>
    </Block>
    <Elt>Element 2</Elt>
</Article>

The class in C# I use to serialize it looks like this :
 [Serializable]
 public class XArticle
 {
     public XArticle()
     {
         Blocks = new List<XBlock>();
         Elts = new List<XElt>();
     }

     [XmlElement("block")]
     public List<XBlock> Blocks { get; set; }

     [XmlElement("elt")]
     public List<XElt> Elts { get; set; }

      /*Plenty of other stuff*/

 }

I also have XBlock and XElt classes. The XBlock class has an innerBlocks attribute that is just a List to allow multiple levels.
My problem lies in the fact that when I try to create my XArticle, Blocks and Elts are stored in 2 separate lists, so of course when I try to serialize it, it serialize a list after the other and I totally lose the order of blocks and elts if they were mixed.
Here is an example of the XML I get instead of the one I posted before :
 <Article>
    <Block name='Block 1'>
        <Elt>Element 1</Elt>
    </Block>
    <Elt>Element 0</Elt>
    <Elt>Element 2</Elt>
</Article>

You can see it serializes all the blocks first then all the Elements inside each node.
I have little knowledge in Serialization and I was wondering if there were an xml instruction or something that could resolve this problem.
A solution that came to my mind is to reorder the Blocks and Elts tags after I created the disorganised xml, but maybe there is a better solution.
PS : I use the System.Xml.Serialization.XmlSerializer.
PPS : Tell me if you need to see the function that transforms the xpath data into X-classes.

A: If you want to mix up types in serialized lists, you should create one property with 2 decoration attributes as follows :
[Serializable]
public class XArticle
{

    [XmlElement(Type = typeof(XBlock), ElementName = "Block")]
    [XmlElement(Type = typeof(XElt), ElementName = "Elt")]
    public List<object> Elements { get; set; }

}

If you fill Elements with the following :
Elements = new List<object> { new XElt { Text = "Element 0" }, new XBlock { Elt = new XElt { Text = "Element 1 " }, Name = "Block 1" }, new XElt { Text = "Element 2 " } };

It produces the xml :
<?xml version="1.0"?>
<XArticle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Elt>Element 0</Elt>
  <Block name="Block 1">
    <Elt>Element 1 </Elt>
  </Block>
  <Elt>Element 2 </Elt>
</XArticle>

Edit :
If you must keep Blocks and Elts properties, you could do as following :
[Serializable]
public class XArticle
{
    [XmlIgnore]
    public List<XBlock> Blocks { get; set; }


    [XmlIgnore]
    public List<XElt> Elts { get; set; }

    [XmlElement(Type = typeof(XBlock), ElementName = "Block")]
    [XmlElement(Type = typeof(XElt), ElementName = "Elt")]
    public List<object> Elements
    {
        get
        {
            return Blocks.Select(b => new KeyValuePair<string, object>(b.Elt.Text, b))
                .Concat(Elts.Select(e => new KeyValuePair<string, object>(e.Text, e)))
                .OrderBy(kvp => kvp.Key).Select(kvp => kvp.Value).ToList();
        }
        set { }
    }

This will create a list ordered by Text property. 
You can replace with any other field you prefer to be ordered by.

A: Thank you very much for your help, I was able to resolve my issue thanks to it! 
For further people it might help, I managed to reorder my final xml simply by creating 2 recursive function :


*

*the first, after the deserialization to transform the List<object> Elements in 2 lists (List<XBlock> Blocks and List<XElt> Elts, remember, they were used everywere in the program and had to be fed).

*the second, before the serialization to merge the 2 lists (Blocks and Elts) into one list (Elements).
