def sort_bed_nicely(bed_file):
    """Sorts BED file but in sorted_nicely order"""
    import pybedtools
    import tempfile
    from ngs_toolkit.utils import sorted_nicely
    if isinstance(bed_file, str):
        sites = pybedtools.BedTool(bed_file)
    elif isinstance(bed_file, pybedtools.BedTool):
        pass
    chrom_names = tempfile.NamedTemporaryFile()
    with open(chrom_names.name, 'w') as handle:
        for chrom in sorted_nicely(sites.to_dataframe()['chrom'].unique()):
            handle.write(chrom + '\n')
    return sites.sort(g=chrom_names.name)
