def METHOD_NAME(paths, index, reverse):
    """Sort list of paths so the order is usable by search.
    This moves the currently selected image to end of the list and the next
    index to the very front.
    Args:
        paths: List of paths to sort.
        index: The currently selected index.
        reverse: If True sort for reverse search, reversing the list.
    """
    if reverse:
        return paths[index::-1] + paths[-1:index:-1]
    return paths[index:] + paths[:index]