<commit_before>package mergesort

func Sort(a []int) {
	// fmt.Printf("Sort: %v\n", a)

	if len(a) == 0 {
		return
	}

	mergesort(a, 0, len(a)-1)
}

func mergesort(a []int, start, end int) {
	// fmt.Printf("mergesort: %v\n", a[start:end+1])

	if end < start+1 {
		return
	}

	mid := (start + end) / 2
	mergesort(a, start, mid)
	mergesort(a, mid+1, end)
	merge(a, start, mid, end)
}

func merge(a []int, start, mid, end int) {
	// fmt.Printf("merge: %v and %v\n", a[start:mid+1], a[mid+1:end+1])

	m := []int{}
	l := start
	r := mid + 1
	for l <= mid || r <= end {
		if r > end || l <= mid && a[l] < a[r] {
			m = append(m, a[l])
			l++
		} else {
			m = append(m, a[r])
			r++
		}
	}

	for i, v := range m {
		a[start+i] = v
	}
}<commit_msg>[mergesort/go] Cleanup<commit_after>package mergesort

func Sort(a []int) {
	// fmt.Printf("Sort: %v\n", a)

	if len(a) == 0 {
		return
	}

	mergesort(a, 0, len(a)-1)
}

func mergesort(a []int, start, end int) {
	// fmt.Printf("mergesort: %v\n", a[start:end+1])

	if end < start+1 {
		return
	}

	mid := (start + end) / 2
	mergesort(a, start, mid)
	mergesort(a, mid+1, end)
	merge(a, start, mid, end)
}

func merge(a []int, start, mid, end int) {
	// fmt.Printf("merge: %v and %v\n", a[start:mid+1], a[mid+1:end+1])

	merged := []int{}
	left := start
	right := mid + 1
	for left <= mid || right <= end {
		if right > end || left <= mid && a[left] < a[right] {
			merged = append(merged, a[left])
			left++
		} else {
			merged = append(merged, a[right])
			right++
		}
	}

	copy(a[start:], merged)
}
{'fraction_non_alphanumeric': 0.22207792207792207, 'fraction_numerical': 0.014285714285714285, 'mean_word_length': 3.0025974025974027, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '1429350', 'n_tokens_mistral': 749, 'n_tokens_neox': 700, 'n_words': 176}