Convenience method to convert this object into an OrderedDict
14555
def as_ordereddict(self):
        """"""
        if six.PY2:
            d = OrderedDict()
            copied = dict(self)
            for key in self:
                d[key] = copied[key]
        else:
            d = OrderedDict(self)
        return d
959449
def dict(self):
        
        from collections import OrderedDict
        SKIP_KEYS = ()
        return OrderedDict(
            (p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in SKIP_KEYS)
357198
def dictfetchone(cursor: Cursor) -> Optional[Dict[str, Any]]:
    
    columns = get_fieldnames_from_cursor(cursor)
    row = cursor.fetchone()
    if not row:
        return None
    return OrderedDict(zip(columns, row))
943962
def format_result(input):
        
        items = list(iteritems(input))
        return OrderedDict(sorted(items, key=lambda x: x[0]))
646982
def from_jsondict(cls, dict_):
        
        fields = [ofproto.oxm_from_jsondict(f) for f
                  in dict_['oxm_fields']]
        return OFPMatch(_ordered_fields=fields)
1036272
function orderObject (unordered) {
  const ordered = {}
  if (typeof unordered !== 'object' || unordered == null || Array.isArray(unordered)) return unordered
  Object.keys(unordered).sort().forEach(function (key) {
    ordered[key] = ((typeof unordered[key] === 'object') && !Array.isArray(unordered[key])) ? orderObject(unordered[key]) : unordered[key]
  })
  return ordered
}
169186
def sort_recursive(data):
    

    newdict = {}

    for i in data.items():
        if type(i[1]) is dict:
            newdict[i[0]] = sort_recursive(i[1])
        else:
            newdict[i[0]] = i[1]

    return OrderedDict(sorted(newdict.items(), key=lambda item: (compare_type(type(item[1])), item[0])))
264108
def _asdict(self):
        """"""
        return OrderedDict((f.name, getattr(self, f.name))
                           for f in self._struct)
504172
def total_ordering(cls):
    """"""
    convert = {  # :off
        '__lt__': [('__gt__', _gt_from_lt),
                   ('__le__', _le_from_lt),
                   ('__ge__', _ge_from_lt)],
        '__le__': [('__ge__', _ge_from_le),
                   ('__lt__', _lt_from_le),
                   ('__gt__', _gt_from_le)],
        '__gt__': [('__lt__', _lt_from_gt),
                   ('__ge__', _ge_from_gt),
                   ('__le__', _le_from_gt)],
        '__ge__': [('__le__', _le_from_ge),
                   ('__gt__', _gt_from_ge),
                   ('__lt__', _lt_from_ge)]
    }  # :on
    # Find user-defined comparisons (not those inherited from object).
    roots = [  # :off
        op
        for op in convert
        if getattr(cls, op, None) is not getattr(object, op, None)
    ]  # :on
    if not roots:
        raise ValueError('must define at least one ordering operation: < > <= >=')
    root = max(roots)  # prefer __lt__ to __le__ to __gt__ to __ge__
    for opname, opfunc in convert[root]:
        if opname not in roots:
            opfunc.__name__ = opname
            setattr(cls, opname, opfunc)
    return cls
983432
def to_dict(self, depth=-1, ordered=True, **kwargs):
        """"""
        if ordered:
            dict_fun = OrderedDict
        else:
            dict_fun = dict
        out = dict_fun()
        out['name'] = self._name
        out['id'] = self._id
        if depth != 0:
            out['children'] = dict_fun([(name, child.to_dict(depth=depth-1))
                                        for name, child in self._children.items()])  # noqa
        return out
181277
def order_columns_in_row(fields, unordered_row):
    
    fields_idx = {f: pos for pos, f in enumerate(fields)}
    return OrderedDict(sorted(unordered_row.items(),
                              key=lambda i: fields_idx[i[0]]))
1240912
def sort_dict(self, data, key):
    ''''''
    return sorted(data, key=itemgetter(key)) if data else []
1183161
function sortObject(obj) {
  assert.ok(_.isObject(obj), 'Parameter should be an object! - ' + util.inspect(obj));
  assert.ok(!_.isArray(obj), 'Parameter should be an object, got array: ' + util.inspect(obj));

  var sortedKeys = _.keys(obj).sort();
  var sortedObjs = [];

  _.each(sortedKeys, function(key) {
    var val = {};
    val[key] = obj[key];
    sortedObjs.push(val);
  });

  return sortedObjs;
}
1210669
def namedtuple_asdict(obj):
    
    if obj is None:
        return obj
    if hasattr(obj, "_asdict"):  # detect namedtuple
        return OrderedDict(zip(obj._fields, (namedtuple_asdict(item)
                                             for item in obj)))
    if isinstance(obj, str):  # iterables - strings
        return obj
    if hasattr(obj, "keys"):  # iterables - mapping
        return OrderedDict(zip(obj.keys(), (namedtuple_asdict(item)
                                            for item in obj.values())))
    if hasattr(obj, "__iter__"):  # iterables - sequence
        return type(obj)((namedtuple_asdict(item) for item in obj))
    # non-iterable cannot contain namedtuples
    return obj
143785
def order(self, last):
        ''''''
        desc = last.desc
        field = last.name
        nested = last.nested
        nested_args = []
        while nested:
            meta = nested.model._meta
            nested_args.extend((self.backend.basekey(meta), nested.name))
            last = nested
            nested = nested.nested
        method = 'ALPHA' if last.field.internal_type == 'text' else ''
        if field == last.model._meta.pkname():
            field = ''
        return {'field': field,
                'method': method,
                'desc': desc,
                'nested': nested_args}
288427
def from_attrdict(cls, attrdict: OrderedNamespace) -> object:
        
        dictionary = attrdict.__dict__
        # noinspection PyArgumentList
        return cls(**dictionary)
383863
def dict(self):
        
        from collections import OrderedDict

        d = OrderedDict(
            [(p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ('data',)])

        if 'list' in self.data:
            d['bundle_count'] = len(self.data['list'])
        else:
            d['bundle_count'] = None

        if self.data:
            for k, v in self.data.items():
                d[k] = v

        return d