Skip to main content
2 of 2
added 408 characters in body

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))

Re: your comment You are talking about datastructures, but what you are really after..is a sorting algorithm that can take an object type and change the a.compareTo(b) call on the fly. In other words, any datastructure will do. Your sorting algorithm just needs to know how to compute the key with which the sorting will be done.

Example: https://wiki.python.org/moin/HowTo/Sorting#Key_Functions