In a script_field I'm trying sort and array of objects by a sub field. What is the correct way to sort these.
Eg each locations has a distance field and i'd like to order the objects in the list by distance.
List locations = params['_source']['locations'];