01-08-2014 10:13 PM - edited 03-15-2019 05:57 AM
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:
MARKETING,14
SALES,32
FINANCE,34
SUPPORT,53
Suggestions?
01-09-2014 01:34 AM
Hi,
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?
Thanks.
G.
01-09-2014 07:13 AM
Gergely,
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.
Thanks!
Kevin
01-09-2014 08:10 AM
Kevin,
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.
G.
01-09-2014 08:03 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide