Changing of sequence in string

Hi all,

I have following information in string:

2018, 2017, 2016,

I would like to receive:

2016, 2017, 2018

As you see the numbers are separated by commas.

Do you have any idea how to solve this problem?

1 Like

use this:

var res=new String(varstring.ToCharArray().Reverse.ToArray())

res should be of type string and var string is the variable containing your input string.

1 Like

If you have only three, then it is easy to pick the least value just by splitting and saving in a new variable.

If you have many, try to split each and then store them in a array and then use the predefined classes to get the least or normal iterations to get the least. @Krzysztof

The result is following:)

@Krzysztof Refer in this threads

Please find the xaml attached.
_Test.xaml (7.3 KB)


  1. First use split Method to split the above string and use delimiter as comma β€œ,”. It will give you output as array of Strings.

Str = β€œ2018, 2017, 2016”

varArray [ ] = Str.Split(","c)

Then try this expression to sort array.

varSortArray [ ] = Array.sort(varArray)

1 Like


if my string is β€œ2020,2019,2018,2017,2016” the result is also β€œ2020,2019,2018,2017,2016” (should be β€œ2016,2017,2018,2019,2020”).

The problem is that these years can be more than 3, eg.
2018, 2017, 2016, 2015, 2014

I have question about last assign. It should be varSortArray = Array.sort(varArray.ToString)?

Hey @Krzysztof,

Leave it as is.varArray is the array and you do not need to convert it to string.


Don’t convert it to string. Let it be as it is array.

It does not work.
There is problem to assign Array.sort(varArray) to vatSortArray
Could you prepare send example in uipath?


Sorry I don’t have system now. Could you please tell me what Error are you getting and show me the process in screenshots. Will check and update you.

@Krzysztof hope this will help you

hello @Krzysztof

Regarding this issue as you can see in the assign activity its sorting your numbers in descending order
To arrange in Ascending order just remove the descending from that code

And this below workflow will just arrange the string in reverse whatever the text be what that means is it’ll place the last text to first whatever that text be
Use this workflow it’ll solve your issue
reverseastring.xaml (5.3 KB)