<commit_before>// Playground - noun: a place where people can play

import Cocoa

//func quicksort<T : Comparable>(data : [T]) {
//    if data.count == 0 {
//        return
//    }
//    
//    self.data = data
//    quickSort(0, toIndex: values.count - 1)
//}

func quickSort<T : Comparable>(inout data : [T], low : Int, high : Int) {
    var i = low
    var j = high
    let pivot = data[low + (high - low) / 2]
    
    while i <= j {
        while data[i] < pivot {
            ++i
        }
        
        while data[j] > pivot {
            --j
        }
        
        if i <= j {
            swapItemAtIndex(&data, i, j)
            ++i
            --j
        }
    }
    
    if low < j {
        quickSort(&data, low, j)
    }
    if i < high {
        quickSort(&data, i, high)
    }
}

func swapItemAtIndex<T : Comparable>(inout data : [T], index : Int, withElementAtIndex : Int) {
    let temp = data[index];
    data[index] = data[withElementAtIndex];
    data[withElementAtIndex] = temp;
}

var data = [10, 3, 2, 12, 5, 6]
quickSort(&data, 0, data.count-1)<commit_msg>Moved the algorithm inside a class<commit_after>// Playground - noun: a place where people can play

import Cocoa

class QuickSort<T : Comparable> {
    
    private var data : [T] {
    get {
        return self.data
    }
    set(newData) {
        self.data = newData
    }
    }
    
    public init() {
        self.data = []
    }
    
    public func sort() {
        if data.count == 0 {
            return
        }
        
        quickSort(0, high: data.count - 1)
    }
    
    private func quickSort(low : Int, high : Int) {
        var i = low
        var j = high
        let pivot = data[low + (high - low) / 2]
        
        while i <= j {
            while data[i] < pivot {
                ++i
            }
            while data[j] > pivot {
                --j
            }
            if i <= j {
                swapItemAtIndex(i, withElementAtIndex: j)
                ++i
                --j
            }
        }
        
        if low < j {
            quickSort(low, high: j)
        }
        if i < high {
            quickSort(i, high: high)
        }
    }
    
    func swapItemAtIndex(index : Int, withElementAtIndex : Int) {
        let temp = data[index];
        data[index] = data[withElementAtIndex];
        data[withElementAtIndex] = temp;
    }
}

var data = [10, 3, 2, 12, 5, 6]
let quickSort = QuickSort<Int>()
quickSort.sort()
var aa = quickSort.data



{'fraction_non_alphanumeric': 0.12379807692307693, 'fraction_numerical': 0.010416666666666666, 'mean_word_length': 1.3556603773584905, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 10, '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': '5983786', 'n_tokens_mistral': 847, 'n_tokens_neox': 796, 'n_words': 222}