Sort the list under the legend


Hi, I need to sort the legend by name in the page attached (under “Comfort Interno”). I tried to sort the array in the js function, inside the function I can see the list ordered but in the page no…someone can help me to solve this issue?