On Dec 24, 2012 9:37 AM, "Pander Musubi" <pander.mus...@gmail.com> wrote:
> > >>> ''.join(sorted(random.sample(cs, 20), key=d.get)) > > > > '5aAàÀåBCçËÉíÎLÖøquùx' > > This doesn't work for words with more than one character: Try this instead: def collate(x): return list(map(d.get, x)) sorted(data, key=collate) I would also probably change "d.get" to "d.__getitem__" for a clearer error message in the case the string contains characters that it doesn't know how to sort.
-- http://mail.python.org/mailman/listinfo/python-list