C# sort Assembly parts

Hi guys,

I have problem guys

  object[] colComp = (object[])((AssemblyDoc)compModelDoc).GetComponents(true);

   foreach(Component2 swCom in colComp)

          {

                 ModelDoc2 swDocParts = swCom.GetPathName();

                  swApp.ActivateDoc2(swDocParts.GetTitle(), false, ref errors); 

          }


I have two parts in the assembly doc then I passed them to colComp object[] array

then I want get their name by ascending order or descending order by using foreach only how can I get this?

I tried this but i only get null

foreach(Component2 swCom in colComp.OrderByDescending(c => c.ToString()) ) 

          {

                 ModelDoc2 swDocParts = swCom.GetPathName();

                  swApp.ActivateDoc2(swDocParts.GetTitle(), false, ref errors); 

          }

Thanks,

Gab

SolidworksApi macros