def reducedicttolist(mydict):
    """
    This function recursively reduces dictionaries with integer keys to lists.
    This is especially useful for unmangling data that comes through with the integer indices as strings,
    in wsgi calls.
    """

    allintegers = True
    for key in mydict:
        value = mydict[key]
        if isinstance(value, dict):
            # recursive call
            returnvalue = reducedicttolist(value)
            mydict[key] = returnvalue

    for key in mydict:
        value = mydict[key]
        try:
            int(value)
        except:
            allintegers=False

    if allintegers:
        returnlist = []
        sortedkeys = sorted(mydict, key=lambda key: float(key))
        for key in sortedkeys:
            returnlist.append(mydict[key])
        return returnlist
    else:
        return mydict