def ordered_groupby(collection, column):
    """Group collection by a column, maintaining the key
    order from the collection.

    Args:
        collection (list): List of flat dictionaries.
        column (str): Column (dict key) by which to group the list.
    Returns:
        grouped (dict): Dict of the column to subcollections.
    """
    # Figure out the group order
    group_order = []
    for row in collection:
        group = row[column]
        if group not in group_order:
            group_order.append(group)
    # Group by in order
    return {group: [row for row in collection
                    if row[column] == group]
            for group in group_order}