Linq query for array sort

Hi folks ,
Can any one help with a linq for operations like sort array of integers in ascending and descending order also adding and subtracting operations on give input array of int.

Explanation will be a cherry on cake☺️

Hi @ashwin.ashok ,

Please have a look.

Hi @sheetal_Bora ,

If you are trying to order items in an array of integers, then you can take advantage of the OrderBy Method like so:


The OrderBy Method sorts the array in Ascending order by default.

If you are trying to perform any other sort of data manipulation, then an example of the expected output would be most appreciated as it would put us in a much better position to assist you.

If you are trying to add an array of integers, then the Sum Method can help you out there:


Want to find the maximum and minimum values?


Kind Regards,
Ashwin A.K

1 Like
  1. arr_result=arr_Data.OrderBy(Function(x) x).ToArray() (For ascending order)
    2.arr_result=arr_Data.OrderByDescending(Function(x) x).ToArray() (For descending order)
    3.For adding and subtract operation you need to first convert it into list
    4.Use Add to collection activity to add data into list(lst_result)
    5.User Remove from collection activity to delete data from list

Descending order failed

Hi @sheetal_Bora ,

Would you be so kind as to explain a bit more on what exactly failed?
Could you try adding breakpoints at each operation to verify whether the operation has been performed or not?

Kind Regards,
Ashwin A.K

It seems you are checking wrong value in message box you are using arrNumbers instead of newOutput

as alreadxy mentioned the origin array was used for the messagebox output. We would recommend to avoid messageboxes etc. and to shift to debugging along with the different panels. We would be faster for inspecting the part result, can prototype statements and do not model outputs only for inspection purpose.

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

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