code: def do_sort(value, case_sensitive=False):
      if not case_sensitive:
          def sort_func(item):
              if isinstance(item, basestring):
                  item = item.lower()
              return item
      else:
          sort_func = None
      return sorted(seq, key=sort_func)