The layers in my map often have many overlapping features and when the popup is opened I'd like to be able to order them by a field in order to have the most relevant features at the top of the stack. Was able to find an older 3.x example of this, but I can't find the equivalent for 4.x. Any suggestions? No need to rewrite this for me, just point me to the right object/method/event if it exists, thanks!
connect.connect(map.infoWindow, "onSetFeatures", function () {
var orderedFeatures = [];
for(var i = 0; i< map.infoWindow.features.length; i++) {
if (map.infoWindow.features[i]._layer.id === 'ImportantLayer') {
orderedFeatures.unshift(map.infoWindow.features[i]);
}
else {
orderedFeatures.push(map.infoWindow.features[i]);
}
}
map.infoWindow.features = orderedFeatures;
});