def page_list(pages, publish_filter=None, limit=None, meta_sort='', reverse=False):
    """Basic sorting and limiting for flatpage objects"""
    if publish_filter is True:
        # Only published
        pages = [p for p in pages if p.meta['published']]
    elif publish_filter is False:
        # Only unpublished
        pages = [p for p in pages if not p.meta['published']]
    else:
        # All pages
        pages = [p for p in pages]
    if meta_sort:
        pages = sorted(pages, reverse=reverse, key=lambda p: p.meta[meta_sort])
    return pages[:limit]