This is a simple function to reverse string array in mel.
1 2 3 4 5 6 7 8 9 |
global proc string[] bc_ReverseList(string $bcInputList[]) { string $bcOutputList[]; for($bcItem in $bcInputList) { stringArrayInsertAtIndex(0, $bcOutputList, strip($bcItem)); } return $bcOutputList; } |
The function can be easily called as shown below
1 2 3 4 |
string $tempStrArray[] = {"red", "green", "blue"}; $tempStrArray = bc_ReverseList($tempStrArray); print $tempStrArray; // Result: blue green red // |