alpaca-13b· Stanford
Arena Human Preference 55K
generate the quick sort in pythobn
- User
generate the quick sort in pythobn
- Assistant
def quick_sort(data): """ This function sorts the given list using the Quick Sort algorithm """
code# setting the pivot to the first element pivot = data[0] # quick sort the list l, r = 0, len(data) - 1 while l < r: # finding the index of the pivot element i = l + (r - l) // 2 # swapping the elements if the pivot is greater than the current element if data[i] > pivot: data[i], data[l] = data[l], data[i] # moving the pivot element to the right l += 1 pivot = data[l] # sorting the remaining elements for i in range(l, r): data[i] = pivot
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.