Re: To Sort multiple arrays (272 Views)
Occasional Contributor
Posts: 11
Registered: ‎07-02-2011
Message 1 of 2 (285 Views)

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
Posts: 4,226
Registered: ‎07-21-2008
Message 2 of 2 (272 Views)

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.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.