code: def _order(self, value, is_reverse=None):
          
  
          def _dict_parser(dict_doc):
              """ dict ordered by:
              valueType_N -> key_N -> value_N
              """
              result = list()
              for key in dict_doc:
                  data = self._order(dict_doc[key])
                  res = (data[0], key, data[1])
                  result.append(res)
              return tuple(result)
  
          def _list_parser(list_doc):
              """list will iter members to compare
              """
              result = list()
              for member in list_doc:
                  result.append(self._order(member))
              return result
  
          # (TODO) include more data type
          if value is None or not isinstance(value, (dict,
                                                     list,
                                                     basestring,
                                                     bool,
                                                     float,
                                                     int)):
              # not support/sortable value type
              value = (0, None)
  
          elif isinstance(value, bool):
              value = (5, value)
  
          elif isinstance(value, (int, float)):
              value = (1, value)
  
          elif isinstance(value, basestring):
              value = (2, value)
  
          elif isinstance(value, dict):
              value = (3, _dict_parser(value))
  
          elif isinstance(value, list):
              if len(value) == 0:
                  # [] less then None
                  value = [(-1, [])]
              else:
                  value = _list_parser(value)
  
              if is_reverse is not None:
                  # list will firstly compare with other doc by it's smallest
                  # or largest member
                  value = max(value) if is_reverse else min(value)
              else:
                  # if the smallest or largest member is a list
                  # then compaer with it's sub-member in list index order
                  value = (4, tuple(value))
  
          return value
docs: Parsing data to a sortable form
          By giving each data type an ID(int), and assemble with the value
          into a sortable tuple.