function a = sort_timer(num_items)
    % Note the declaration of steps.
    steps = 0;

    % The following functions are *nested functions*.  They are called such
    % because they are nested inside of another function (specificallly,
    % sort_timer).  Nested functions have access to any variables declared
    % inside their "parent" function.
    function b = merge(list1, list2)
        i = 1;
        j = 1;
        merged = [];

        while i <= size(list1,2) && j <= size(list2,2)
            % Since we declared steps outside of merge, but in sort_timer, it is
            % considered *non-local* to merge.  Any changes made to step in
            % merge will be reflected elsewhere in sort_timer after merge has
            % run.
            steps = steps + 1;
            if list1(i) < list2(j)
                merged = [merged, list1(i)];
                i = i + 1;
            else
                merged = [merged, list2(j)];
                j = j + 1;
            end
        end

        merged = [merged, list1(i:size(list1,2))];
        b = [merged, list2(j:size(list2,2))];
    end

    function b = merge_sort(nums)
        if size(nums,2) == 1
            b = nums;
            return;
        end

        % another use of non-local step.
        steps = steps + 1;
        b = merge(merge_sort(nums(1:floor(size(nums,2)/2))), merge_sort(nums(floor(size(nums,2)/2) + 1:size(nums,2))));
    end

    random_nums = [];
    for i = 1:num_items
        random_nums = [random_nums, randi(2^16)];
    end

    merge_sorted = merge_sort(random_nums);
    merge_steps = steps;

    % What do you think we need to do to steps before using it to count the
    % steps of insertion_sort?

    a = [merge_steps];
end
