code: def argsort2(indexable, key=None, reverse=False):
      if isinstance(indexable, dict):
          vk_iter = ((v, k) for k, v in indexable.items())
      else:
          vk_iter = ((v, k) for k, v in enumerate(indexable))
      if key is None:
          indices = [k for v, k in sorted(vk_iter, reverse=reverse)]
      else:
          indices = [k for v, k in sorted(vk_iter, key=lambda vk: key(vk[0]),
                                          reverse=reverse)]
      return indices