How to arrange ages in ascending order dynamically

How to arrange ages in ascending order dynamically 0-30 181-365 31-60 365-700 91-180
in this format.

@anjani_priya,

Try modifying this code

1 Like

Hi @anjani_priya

Input = New List(Of String) From {β€œ0-30”, β€œ181-365”, β€œ31-60”, β€œ365-700”, β€œ91-180”}

Order = Input.OrderBy(Function(range) Convert.ToInt32(range.Split("-"c)(0))).ToList()

Output = String.Join(β€œ,”, Order)


If you found helpful, feel free to tick as a solution.
Happy Automation

Column data should also change the index

@anjani_priya

Yes, since the data is now sorted in ascending order, the index positions have changed accordingly. If the index is being used for any reference or mapping, it should be updated to match the new order.

Happy Automation

@anjani_priya

Please try this

Say you are getting a string in the above given format

Str.split(" "c).OrderBy(function(x) cint(x.split("-"c).First)).Toarray this will give array of strings in ascending order

Cheers