Recently I was in need of sorting the elements in the container and use them .
I am not sure how far this code is helpful to you guys. Below code will help to sort the elements in the container. If there is already any function to do this, then kindly ignore.
static void SR_sortContainer(Args _args)
container con = [5,1,2,’Sumit Loya’,9, ‘Ashish singh’, NoYes::No];
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);
Please note: Even though you have different data types in the container, the above code will sort the elements. [Recommended is similar datatypes, next question would be y not use set which result in ascending order but disadvantage is set will not allow duplicates]