<commit_before>"""
adapted from 'The Object of Data Abstraction and Structures Using Java'
"""


def sort(a):
    do_merge_sort(a, 0, len(a)-1)


def do_merge_sort(a, lo, hi):
    if lo < hi:
        mid = (lo + hi) / 2
        do_merge_sort(a, lo, mid)
        do_merge_sort(a, mid+1, hi)
        merge(a, lo, hi)


def merge(a, lo, hi):
    mid = (lo + hi) / 2
    l_idx = lo
    r_idx = mid+1
    tmp = []
    tmp_idx = 0
    while (l_idx <= mid) and (r_idx <= hi):
        if a[l_idx] < a[r_idx]:
            tmp.append(a[l_idx])
            l_idx += 1
        else:
            tmp.append(a[r_idx])
            r_idx += 1
        tmp_idx += 1

    # copy remaining values from left list into tmp
    for j in xrange(l_idx, mid+1):
        tmp.append(a[j])
        tmp_idx += 1

    # copy remaining values from right list into tmp
    for j in xrange(r_idx, hi+1):
        tmp.append(a[j])
        tmp_idx += 1

    # copy tmp back into a
    for j in xrange(lo, hi+1):
        a[j] = tmp[j-lo]<commit_msg>Update merge_sort.py<commit_after>"""
adapted from 'The Object of Data Abstraction and Structures Using Java'
"""


def sort(a):
    do_merge_sort(a, 0, len(a)-1)


def do_merge_sort(a, lo, hi):
    if lo < hi:
        mid = (lo + hi) / 2
        do_merge_sort(a, lo, mid)
        do_merge_sort(a, mid+1, hi)
        merge(a, lo, hi)


def merge(a, lo, hi):
    mid = (lo + hi) / 2
    l_idx = lo
    r_idx = mid+1
    tmp = []
    while (l_idx <= mid) and (r_idx <= hi):
        if a[l_idx] < a[r_idx]:
            tmp.append(a[l_idx])
            l_idx += 1
        else:
            tmp.append(a[r_idx])
            r_idx += 1

    # copy remaining values from left list into tmp
    for j in xrange(l_idx, mid+1):
        tmp.append(a[j])

    # copy remaining values from right list into tmp
    for j in xrange(r_idx, hi+1):
        tmp.append(a[j])

    # copy tmp back into a
    for j in xrange(lo, hi+1):
        a[j] = tmp[j-lo]
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.013333333333333334, 'mean_word_length': 1.8989598811292718, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7505754', 'n_tokens_mistral': 771, 'n_tokens_neox': 742, 'n_words': 220}