Wednesday, April 2, 2014

Dynamics AX Sorting Container

static void SR_sortContainer(Args _args)
{
container con = [5,1,2,'Sumit Loya',9, 'Ashish singh', NoYes::No];
str temp1;
str temp2;
int i;
int j;
container sorCon;
;
sorCon = con;
// Sort the container
for (i = 1; i <= conlen(sorCon); i++)
{
for (j = i + 1; j <= conlen(sorCon); j++)
{
temp1 = conpeek(sorCon, j);
temp2 = conpeek(sorCon, i);
if (temp1 < temp2)
{
sorCon = condel(sorCon, j, 1);
sorCon = conins(sorCon, j, temp2);
sorCon = condel(sorCon, i, 1);
sorCon = conins(sorCon, i, temp1);
}
}
}
conview(sorCon);
}

No comments:

Post a Comment