Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

How to sort a multidimensional array in UCCX

In a UCCX script, I would normally use a Do step to sort a one-dimensional array with this:

Do {

java.util.Arrays Arrays.sort(strInformation);


But, now I have a two-dimensional array with values such as this:

strInformation[0][0] = "SALES"

strInformation[0][1] = "32"

strInformation[1][0] = "MARKETING"

strInformation[1][1] = "14

strInformation[2][0] = "SUPPORT"

strInformation[2][1] = "53"

strInformation[3][0] = "FINANCE"

strInformation[3][1] = "34"

I need to sort the array on the 2nd dimension (the numeric values) so it would be in this order:







How to sort a multidimensional array in UCCX


if the numeric values are unique, I would create a Map, perhaps a TreeMap with the numbers as keys and strings as values.

But can you please explain why do you need such a structure?



New Member

How to sort a multidimensional array in UCCX


There is potential for both columns to be strings.  I was just using numeric as an example.  I am looping through a db get step to retrieve multiple rows from a stored procedure specified in the db read step.  In a one-dimensional array, I've simply assigned the value retrieved to index [0], then loop through to get the next row and assign that to index [1], and so on.

I now have a requirement where I have multiple values that I need to put in a two-dimensional array as shown in my original post.  So, taking the same db get loop logic, the first row's values would be put into [0][0] and [0][1].  Then, loop through the db get step again to get the next row and assign the values received on that into [1][0] and [1][1], and so on.  Once I loop through all rows (and hit the No Data branch), I need to make sure that this array is sorted on the 2nd column.

I may be able to have the database team change their stored procedure to return the values to UCCX already sorted, but would like to verify it is sorted within my script. Again, I've done this many times on a one-dimensional array, but not on a two-dimensional array.



Re: How to sort a multidimensional array in UCCX


sorry, it's been a long day. Would you mind telling me how this array is being used - I am trying to understand the application from a global point of view.

Thanks in advance.


Re: How to sort a multidimensional array in UCCX

Just do a manual sort...there are many algorithms out there for this..I've attached an image of the one you always learn in basic programming (Bubble Sort..if there's lotsa data then this method isn't efficient)..