Your problem can be broken down into two parts: - a sorting algorithm that takes a `value` from a given element - a method to choose which `value` to extract, given a feature name So something like (python-like pseudocode): data = new MyDataStructure() #Insert some values into it.. #... def extract_feature(myObject, feature_name): return myObject.getFeature(feature_name) print sorted(data, (key=lambda x: extract_feature(x))