On May 11, 1:22 am, philly_bob <[EMAIL PROTECTED]> wrote: > > I have a population of five algorithms. Each Alg has a method, > Alg.accuracy(), which calculates its accuracy. Running the accuracy > method on each Alg, I end up with a list of accuracies like [0.75, > 0.10, 0.45, 0.80, 0.45] > > Now I want to store the algorithms and associated accuracies in a > file, in descending order of accuracy. > > Here's how I do it now. There must be a better way! This method is > inelegant, and does not handle at all the issue of what to do with > duplicate accuracies, such as the two different algorithms with 0.45 > accuracies in the example above. It merely saves the first of the > duplicates -- not what I want at all. > > I want to end up with a file: > > 0 AlgD 0.80 > 1 AlgA 0.75 > 2 AlgC 0.45 > 3 AlgE 0.45 > 4 AlgB 0.10
algs.sort(key=Alg.accuracy, reverse=True) -- http://mail.python.org/mailman/listinfo/python-list