Hi Saad,
Have you tried using a custom JavaScript function, this would be the only way you can currently do this as we do not support sorting variables in an array in the app with any in-built functions. Here is a link to EAC with details about using JS functions in the app, note this is still beta functionality:
Here is an example pulldata() function you could use to get an array of all the values of a field from the repeat and pass it to a JS function:
pulldata("@javascript", "functions.js", "sumField", ${r1}, "r1_decimal")
Phil.