def insertion_sort(collection):
    """
    Counts the number of comparisons (between two elements) and swaps
    between elements while performing an insertion sort

    :param collection: a collection of comparable elements
    :return: total number of comparisons and swaps
    """
    comparisons, swaps = 0, 0

    for x in range(1, len(collection)):
        # element currently being compared
        current = collection[x]

        # comparing the current element with the sorted portion and swapping
        while True:
            if x > 0 and collection[x - 1] > current:
                collection[x] = collection[x - 1]
                x -= 1
                collection[x] = current

                comparisons += 1
                swaps += 1
            else:
                comparisons += 1
                break

    return comparisons, swaps