def compress_list(list_to_compress):
    """
    This function compress a list while maintaining order,
    I.e: [1, 6, 4] is converted in [0 ,2, 1].
    """
    if list_to_compress == []:
        return list_to_compress
    compressed_list = []
    for x in range(len(list_to_compress)):
        compressed_list.append(0)
    num = 0
    for x in range(max(list_to_compress) + 1):
        number = min(list_to_compress) + x
        if number in list_to_compress:
            compressed_list[list_to_compress.index(number)] = num
            num += 1
    return compressed_list
