def sort_gtf(giter, chrom_order=None):
    """ Sort GTF

    Sort GTF records by chromosome and start position

    Args:
        giter (iterable): List of GTFLine or GTFCluster objects
        chrom_order (list): Chromosome sort order. Default is alphabetical.

    Returns:
        list: Sorted GTF records.

    """
    ret = sorted(giter, key=lambda x:x.start)
    if chrom_order is None:
        ret.sort(key=lambda x:x.chrom)
    else:
        c_d = {k:i for i,k in enumerate(chrom_order)}
        ret.sort(key=lambda x:c_d[x.chrom] if x.chrom in c_d else x.chrom)
    return ret