我有一个 Arraylist,里面有一堆对象都是同一个类(DistributedApps)。
构造函数:
public Distributedapps(string appName, string devName, string description, double size, int estLife,double price, int downloads,int ratings,string distributor, double annLicenceFee, int maxUsers)
:base(appName,devName,description,size,estLife,price,downloads,ratings)
我希望 Insertionsort 对这个列表(DeployedApps)按应用程序大小(大小)降序排序
public void DeployInsertionSortAppSizeDeployed()
{
Console.WriteLine("INSERTION SORT ON APP SIZE DEPLOYED!");
int II;
Distributedapps Temp, PrTemp;
for (int IO = 1; IO <= (Count(DeployedApps) - 1); IO++)
{
Temp = (Distributedapps)DeployedApps[IO];
II = IO;
PrTemp = (Distributedapps)DeployedApps[II - 1];
while ((II > 0) && (PrTemp.GetSize().CompareTo(Temp.GetSize()) <= 0))
{
DeployedApps[II] = DeployedApps[II - 1];
II -=1;
}
DeployedApps[II] = Temp;
}
Console.WriteLine("DONE!");
}
如果排序代码看起来不错并且没有错误,我会尝试在之前和之后发布列表图片。