if sorted([a[0].lower(), b[0].lower()]).index(a[0].lower()) == 0:
    return -1
elif sorted([a[0].lower(), b[0].lower()]).index(a[0].lower()) == 1:
    return 1
else:
    raise ValueError('Unhandled condition for values %s, %s' % (a, b))
if isinstance(obj, collections.Mapping):
    return collections.OrderedDict((key, sort_it(value, sort_order=
        sort_order)) for key, value in sorted(list(obj.items()), key=cmp_to_key(
        cmp_func)))
elif isinstance(obj, iterable_types):
    pass
python - complex sorting of nested data