Lonnie Princehouse wrote: > Right, but suppose it's expensive to generate each part of the key - > e.g. a database query or some kind of hash, so it doesn't make sense to > compute the whole key in advance if the first part is sufficient to > establish an ordering most of the time. This is what I had in mind (I > should have been more clear about that)
Yeah, that's probably a reasonable use case for the cmp= argument, as is any case where you're *really* tight for memory (the key= sort requires small extra auxiliary structures to hold the key values). For newbies though, I still suspect that key= is the easiest and fastest answer to most sorting problems. Advanced users will, of course, need more advanced techniques. =) STeVe -- http://mail.python.org/mailman/listinfo/python-list