def custom_sort(dictionary, sort_top_labels, sort_bottom_labels):
    """ Given a dictionary in the form of

            {'<a_label>': {
                          'label': '<a_label>'
                          'value': '<a_value>'
                          },
                          ...
            }

        and two lists (for top and bottom)

            ['<a_label>', '<c_label>', '<b_label>', ...]

        return a list of the dictonaries values ordered

            <all top items found in dictionary, in the given order>
            <others>
            <all bottom items found in dictionary, in the given order>
    """

    ret = []
    for l in sort_top_labels:
        if l in dictionary:
            ret.append(dictionary[l])
    for label, facet in dictionary.items():
        if label not in sort_top_labels + sort_bottom_labels:
            ret.append(facet)
    for l in sort_bottom_labels:
        if l in dictionary:
            ret.append(dictionary[l])
    return ret