<commit_before># Copyright 2015 <NAME> <<EMAIL>>
# This file is licensed under the terms of the MIT License.
# See LICENSE.txt for details.

from random import randrange
import sys

from ..algorithm import SortingAlgorithm

def _partition(xs, beg, end, select_pivot):
    pivot = select_pivot(xs, beg, end)
    xs[pivot], xs[end] = xs[end], xs[pivot]
    for i in range(beg, end):
        if xs[i] <= xs[end]:
            xs[i], xs[beg] = xs[beg], xs[i]
            beg += 1
    xs[beg], xs[end] = xs[end], xs[beg]
    return beg

def _quicksort(xs, beg, end, select_pivot):
    if beg < end:
        pivot = _partition(xs, beg, end, select_pivot)
        _quicksort(xs, beg, pivot - 1, select_pivot)
        _quicksort(xs, pivot + 1, end, select_pivot)

def _select_first(xs, beg, end):
    return beg

def _select_second(xs, beg, end):
    return beg + 1
<commit_msg>quicksort: seed RNG<commit_after># Copyright 2015 <NAME> <<EMAIL>>
# This file is licensed under the terms of the MIT License.
# See LICENSE.txt for details.

from random import randrange, seed
import sys

from ..algorithm import SortingAlgorithm

seed()

def _partition(xs, beg, end, select_pivot):
    pivot = select_pivot(xs, beg, end)
    xs[pivot], xs[end] = xs[end], xs[pivot]
    for i in range(beg, end):
        if xs[i] <= xs[end]:
            xs[i], xs[beg] = xs[beg], xs[i]
            beg += 1
    xs[beg], xs[end] = xs[end], xs[beg]
    return beg

def _quicksort(xs, beg, end, select_pivot):
    if beg < end:
        pivot = _partition(xs, beg, end, select_pivot)
        _quicksort(xs, beg, pivot - 1, select_pivot)
        _quicksort(xs, pivot + 1, end, select_pivot)

def _select_first(xs, beg, end):
    return beg

def _select_second(xs, beg, end):
    return beg + 1

{'fraction_non_alphanumeric': 0.1285551763367463, 'fraction_numerical': 0.009101251422070534, 'mean_word_length': 3.0906976744186045, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, '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': '4093651', 'n_tokens_mistral': 687, 'n_tokens_neox': 628, 'n_words': 202}