Sorting help. Insertion sort c# -


i have arraylist bunch of objects of same class(distributedapps).

constructor:

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) 

i want insertionsort sort list(deployedapps) descending on app size(size)

public void deployinsertionsortappsizedeployed()     {         console.writeline("insertion sort on app size deployed!");         int ii;         distributedapps temp, prtemp;         (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!");     } 

i try post pictures of list before , after if sort code looks fine , bug isnt it.

just know internet fixed it...

            console.writeline("insertion sort on app size deployed!");         apps temp, prtemp;         int ii;         (int io = 1; io <= (count(deployedapps) - 1); io++)         {             temp = (apps)deployedapps[io];             prtemp = (apps)deployedapps[io - 1];             ii = io;             while ((ii>0)&&(temp.getsize()>=prtemp.getsize()))             {                 swapdep(ii, ii - 1);                 ii = ii - 1;                 if (ii >= 1)                 {                     temp = (apps)deployedapps[ii];                     prtemp = (apps)deployedapps[ii - 1];                 }             }          }         console.writeline("done!"); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -