Sorting the elements in the container .
Wrote this code in Job.
static void LegendContainerSort(Args _args)
{
container con = [999,9,9999,"Suresh",99, "Legend", "Bala", 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