5 Nov 2015

Sorting Data in containers + AX 2012


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:

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...