def sort_by(array, key, descending=False):
    """
    Sort an "array" by "key".

    >>> sort_by([{'a': 10, 'b': 0}, {'a': 5, 'b': -1}, {'a': 15, 'b': 1}], 'a')
    [{'a': 5, 'b': -1}, {'a': 10, 'b': 0}, {'a': 15, 'b': 1}]

    :param tp.List[tp.Mapping] array: list of dicts.
    :param str key: key name to use when sorting.
    :param bool descending: if True sort will be descending.
    :return tp.List[tp.Mapping]: a by "key" sorted list.
    """
    return list(sorted(array, key=lambda k: k[key] if k[key] is not None else "", reverse=descending))