sort Featureset for more then one field
how can I use the sort Featureset activity for more then one field?
the origin of this problem is related to query Relationship. While the ArcGIS REST API allows the order parameter it is not availably in the workflow activity.
-
Best way is to use the query activity (instead of query relationship). There you can set the order for many fields.
another solution is to add a create value activity and inside a javascript function which takes the featureset as input and returns the sorted featureset.
=function(features){
features.sort((a, b) => {
const attrA = a.attributes;
const attrB = b.attributes;
// 1. Sort by ART (Number)
if (attrA.ART !== attrB.ART) {
return attrA.ART - attrB.ART;
}
// 2. Sort by MEDIUM (Number)
if (attrA.MEDIUM !== attrB.MEDIUM) {
return attrA.MEDIUM - attrB.MEDIUM;
}
// 3. Sort by SUBMEDIUM (String)
// localeCompare is the best way to handle string comparison
if (attrA.SUBMEDIUM !== attrB.SUBMEDIUM) {
return attrA.SUBMEDIUM.localeCompare(attrB.SUBMEDIUM);
}
// 4. Sort by JAHR (Number)
return attrA.JAHR - attrB.JAHR;
});
return features;
}
($inputobject.features)
1
Vous devez vous connecter pour laisser un commentaire.
Commentaires
1 commentaire