Your whatitis
variable is just a string. Strings don’t have a sort()
property. You need to get your items sorted before you run the forEach
method to build the whatitis
string.
sort()
still won’t help you here though because you’ve run into one of the cases with nashorn where java and javascript objects are getting mixed together. Once you have done this:
ir.getItem("gBatterycheck").members
.stream()
you’re working with a java stream which does have a sorted()
method, but you have still have your work cut out for you there. Rich (of course) has a better explanation: