Skip to main content

I'm working with groups of features and I want minimize the number of blocking transformers in my workflow. Right now I'm using a Sorter to sort features in each group and a PythonCaller to make some attribute manipulation and comparison. Both transformers block the flow so  I wanted to get rid of the Sorter and do the feature sorting inside the PythonCaller but I don't see how to do it.

Once I have the list of features, what should I do to sort them by one or any number of attributes?

 

Thank you!

 

import fme
import fmeobjects
 
class FeatureProcessor(object):
 
    def __init__(self):
        self.feature_list = Â]
 
    def input(self, feature):
        self.feature_list.append(feature)
 
    def close(self):
        pass
 
    def process_group(self):
        for feature in self.feature_list:
             ## ...

 

 

Have a look at the tutorial here: https://www.geeksforgeeks.org/sort-a-list-of-objects-by-multiple-attributes-in-python/

You'll want to skip the "for" loop on line 16 and pass self.feature_list directly to the sort() function.


Reply