HPE Service Manager / Service Center Support and News Forum
Showing results for 
Search instead for 
Do you mean 

To Sort multiple arrays

Occasional Contributor

To Sort multiple arrays

We have multiple arrays and we need to sort them all based on one array. Like we have three arrays a, b, c so we need that if we sort a then b and c should be sorted using a.....I was searching the forum and find the below link where the requestor is doing the exact thing that I need but there is no solution given by him....... Can someone please help



Honored Contributor Honored Contributor

Re: To Sort multiple arrays

Sounds like what you really wanted was a structured array, not three separate arrays... but, let's assume you have what you have described here, with an array field named a, an array field named b, and an array field named c.


Try the following formatctrl calculation.  modify to use your field names.


1 in $L.sortArray=a in $file; 2 in $L.sortArray=b in $file; 3 in $L.sortArray = c in $file;$L.void=rtecall("sort", $L.rc, $L.sortArray, 0, 0); a in $file = 1 in $L.sortArray;b in $file=2 in $L.sortArray;c in $file=3 in $L.sortArray



What this does -

First, it copies all of your three separate array fields into a variable array of arrays called $L.sortArray.  Then, it uses the "sort" rtecall to sort that array alphabetically.  Then, after the sort is complete, it puts the sorted data back into their respective fields in your record.


Try that.