input: [\'abc\', \'cab\', \'cafe\', \'face\', \'goo\'] output: [[\'abc\', \'cab\'], [\'cafe\', \'face\'], [\'goo\']]
The problem is simple: it grou
not a one liner but a solution...
d = {} for item in input: s = "".join(sorted(item)) if not d.has_key(s): d[s] = [] d[s].append(item) input2 = d.values()