how to sort desc an array

I have an array of 12 element a need to find the bigger value (all the value are integer).

how i can do that in axapta?

If you have an array object (collection class), you cannot sort it, as the values are stored sequentially. You can iterate over it and determine the largest value that way. Here is a job I wrote to demonstrate this. Are you sure you are talking about an array object? See here for reference (

static void JobFindLargestValue(Args _args)


Array array = new Array(Types::Integer);

int largestValue = 0;

int counter;


// Fill the array with 12 random numbers, 1-20

for(counter=1; counter<=12; counter++)

array.value(counter, xGlobal::randomPositiveInt32() mod 20);

// Iterate over it to find the largest value

for(counter=1; counter<=array.lastIndex(); counter++)

largestValue = (array.value(counter) > largestValue) ? array.value(counter) : largestValue;

info(strfmt(“Array contents: %1”, array.toString()));

info(strfmt(“The largest value is: %1”, largestValue));



Please mark the answer as an accepted solution if it works for you. Glad I could help :slight_smile:

Hi Alex,

I have an issue relating to ItemId. What i have to do is that, Suppose i have several ItemId’s Like “3012-AO-08023-A, 3012-AO-08023-B, 3012-AO-08023-C”& so-on other series, Now i want to sort these Item id and want to get the last one, like if the series is “3012-AO-08023” then its last value i.e.“3012-AO-08023-C” will print on screen.

Please suggest some solution to it, i am using Ax-2012.

Thanks & Regards