I am getting some runtime values from a JSON response in my Karate based API Automation. I am storing them into an ArrayList like:
   * def ArrayList = Java.type('java.util.ArrayList')
   * def Collections = Java.type('java.util.Collections')
  ArrayList al = new ArrayList();
  * eval for(var i = 0; i < actualPrice.length; i++) expectedPrice.add(actualPrice[i])
When I printed the list, the output was :
[-150, -210, -100, -112.5]
Above output, When I applied to sort with the help of Collections.sort(al), It threw me the following error:
class java.lang.Integer cannot be cast to class java. lang.Double (java.lang.Integer and java.lang. Double is in module java.base of loader.
I need to use Asc/Desc sorting in the Karate feature file. Can someone please help me here?
Java Equivalent Code is:
    ArrayList al = new ArrayList();
    al.add(-150);
    al.add(-210);
    al.add(-100);
    al.add(-112.5);
    System.out.println(al);
    Collections.sort(al);
 
     
    