title: Simple way to group items into buckets
body: <p>I often want to bucket an unordered collection in python. <a href="http://docs.python.org/library/itertools.html#itertools.groupby"><code>itertools.groubpy</code></a> does the right sort of thing but almost always requires massaging to sort the items first and catch the iterators before they're consumed.</p>
  
  <p>Is there any quick way to get this behavior, either through a standard python module or a simple python idiom?</p>
  
  <pre><code>&gt;&gt;&gt; bucket('thequickbrownfoxjumpsoverthelazydog', lambda x: x in 'aeiou')
  {False: ['t', 'h', 'q', 'c', 'k', 'b', 'r', 'w', 'n', 'f', 'x', 'j', 'm', 'p',
      's', 'v', 'r', 't', 'h', 'l', 'z', 'y', 'd', 'g'],
   True: ['e', 'u', 'i', 'o', 'o', 'u', 'o', 'e', 'e', 'a', 'o']}
  &gt;&gt;&gt; bucket(xrange(21), lambda x: x % 10)
  {0: [0, 10, 20],
   1: [1, 11],
   2: [2, 12],
   3: [3, 13],
   4: [4, 14],
   5: [5, 15],
   6: [6, 16],
   7: [7, 17],
   8: [8, 18],
   9: [9, 19]}
  </code></pre>