I really do need to sort. It is complicated and I haven't said why, but it will help in finding similar keys later on. Sorry I can't be more precise, this has to do with my research.
Your two other suggestions with itertools and operator are more useful, but I was mostly wondering about performance issue. Is this reasonnable to do on 10^8 elements with repeats in the keys? I guess I should just try and see for myself. -- http://mail.python.org/mailman/listinfo/python-list