private IEnumerable<SerializerContainer> SortList(IEnumerable<SerializerContainer> listParam)
{
if (!listParam.Any()) { return Enumerable.Empty<SerializerContainer>(); }
int listParamCount = listParam.Count();
SerializerContainer[] scArray = new SerializerContainer[listParamCount];
if (!listParam.Any()) { return scArray.AsEnumerable(); }
List<SerializerContainer> imList = listParam.FilterBySource("XXX").ToList();
List<SerializerContainer> dmList = listParam.FilterBySource("YYY").ToList();
imList.Sort();
dmList.Sort();
int idx;
for (int i = imList.Count - 1; i >= 0; i--)
{
if (imList[i].Order >= listParamCount)
{
idx = listParamCount - 1;
}
else
{
idx = imList[i].Order - 1;
}
while (scArray[idx] != null)
{
idx--;
}
if (idx >= 0)
{
scArray[idx] = imList[i];
}
else
{
throw new ArgumentOutOfRangeException(@"The index for the configuration list sort operation is less than zero.");
}
}
idx = 0;
foreach (SerializerContainer sc in dmList)
{
while (scArray[idx] != null)
{
idx++;
}
scArray[idx] = sc;
}
return scArray.AsEnumerable();
}