Unanswered question

Sorting in Javascript Action

I have captured all values to json which is like this:
when i try to use sort function in java script action like below:
its throwing me an error cant find function sort in object .
I have to find an highest element in an array by sorting from highest to lowest or viceversa here in my case my desired output should be like below:
input: ["2.13","1.212","1.313","13.23","20.666"]
Desired output: ["1.212","1.313","2.13","13.23","20.666"]

shiva shanker P.
shiva shanker P.

shiva shanker P.

3 / 100


I've tried the JS code below and it did the job.

var captured_json = ["2.13","1.212","1.313","13.23","20.666"]
var sorted = captured_json.sort(function(a, b){return a-b});
logger.debug("value sorted: "+sorted);

update... don't forget this is a text sort, not numbers, so doesn't quite match your desired output.

2020/11/05 08:21:26 DEBUG - neoload.JavaScript.script: sort=1.212,1.313,13.23,2.13,20.666