I have captured all values to json which is like this:
captured_json=["2.13","1.212","1.313","13.23","20.666"]
when i try to use sort function in java script action like below:
captured_json.sort()
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"]
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);
mine also worked
var captured_json=["2.13","1.212","1.313","13.23","20.666"]
logger.debug("sort="+captured_json.sort());
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
I added the function so it can sort the values as numeric values otherwise like Neil said it's a text sort.
superb, learning all the time