def subsets(l,ln, partial=[]):
  """ Generates the subsets of l that have ln elements. """
  if len(partial) == ln:
    return [partial]
  results = []
  for x in l:
    if not partial or x >= partial[-1]:
      nextp = partial[:]
      nextp.append(x)
      nextl = l[:]
      nextl.remove(x)
      results.extend(subsets(nextl,ln,nextp))
  return results