How do I bring the last item of an array to the beginning

Hi everyone

I have a String Array with the length of 5 (new String(5){}). Let’s say we fill the array with some strings and it looks like {“two”, “three”, “one”, null, null)

What I would like to do is to bring the last item that is in this array, in this example “one” to the beginning,so that it will look like {“one”, “two”, “three”, null, null).

Does anyone have an idea how I could do it the easiest way?

Thank you!

Hi @Blerton_Ismaili,

There is no direct way or activity to do this, May I know why you need to do this.

You can get index of the “one”, based on the first null with this line of code

Array.FindIndex(arrStringArray, Function(i) i Is Nothing OrElse i.Length = 0)

Based on that you can remove it and insert it at first.

Hi,

I have an array with document paths and the document that comes into the array the last is the one I would need to have in the beginning, since I am creating a PDF collection out of the array in the end. Do you probably know how I can shift the items one index further to have the last one added to index 0?

One is not the last item in your array.

If you want to reverse the order, then use an invoke method activity with the object as the array.