Changing the sequence of element in an array

In the beginning,
I want to change the sequence of each element in an array like this:
2

But, I have no idea how to do, so, I try to make another array like this:
1

and please also refer to:
Main.xaml (19.2 KB)

But, It didn’t work.

In my opinion, the Str_Array_Test in my workflow must not be changed, but it has been changed.
please someone help me!

Hi @yhPark

You can use Invoke Method activity to achieve your case as below.

Array.ConstrainedCopy(Str_Array_Test.Concat(Str_Array_Test).ToArray, Str_Array_Test.Length - 1, Str_Array_Test, 0, Str_Array_Test.Length)

@yhPark The order that you want the array to appear , Is it in Ascending Order?

Check this workflow, @yhPark
Reverse_Array.zip (13.0 KB)

1 Like

No, It is not Ascending. I want to move the last item to the first, and move one space back for the others.

Checked with Reverse_Array workflow @yhPark???..

Thank you, but the result that I want is:
before: 3, 2, 1;
after: 1, 3, 2

Whether the values inside the array will be constant, like ‘3’???

No, it is just an example to explain.
All I want is,
move the last item of some array to the first;
move the other items of the array to one space back;
Array before: (1st, 2nd, 3rd, …, last-1, last)
Array after: (last, 1st, 2nd, 3rd, …, last-1)
The Array type is not limited to integer, (string, files, and so on)

Could you please explain more details for define invoke method?
(where can I put the code above to invoke method) Sorry, ioi…

Hi @yhPark

refer to below sample.

1

1 Like

@yhPark Can you Check this workflow :
Main.xaml (17.3 KB)

I guess this is the Output you needed :sweat_smile:

It works perfectly!!
Thank you very much!!

  1. Create new array with same length as the input array.
  2. Move the last item in the input array as first item in new array.
  3. Use Array.Copy method to move all other items starting from index 0 to last but one item to the new array starting from 1st position,

Array.Copy(arIntArray, 0, arIntNewArray, 1, arIntArray.Length -1);
Capture

ChangeArraySequence.xaml (7.0 KB)

Hope this helps!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.