大概试了一下,效果不如 v1 7B-Chat

#7
by J22 - opened

输出了多余的 ```、"""。

    ________          __  __    __    __  ___ (通义千问)
   / ____/ /_  ____ _/ /_/ /   / /   /  |/  /_________  ____
  / /   / __ \/ __ `/ __/ /   / /   / /|_/ // ___/ __ \/ __ \
 / /___/ / / / /_/ / /_/ /___/ /___/ /  / // /__/ /_/ / /_/ /
 \____/_/ /_/\__,_/\__/_____/_____/_/  /_(_)___/ .___/ .___/
You are served by QWen2,                      /_/   /_/
with 7721324544 (7.7B) parameters.

You > write a quick sort function in python
A.I. > Certainly! Here's a simple implementation of the QuickSort algorithm using the Python quicksort module (since Python 3.8, as it's a built-in algorithm in the list type) is as follows:

```python
```python
# Using Python 3, as quicksort is built-in
def quicksort(arr):
    """  
    # Base case: empty list, no need to sort
    if not arr:
        return arr

    # Choose pivot (arbitrary element, usually the last)
    pivot = arr[-1]
    pivot_value = arr.pop()

    # Partition the array into three parts
    less, equal, greater = [], [], []

    for item in arr:
        if item < pivot_value:
            less.append(item)
        elif item == pivot:
            equal.append(item)
        else:
            greater.append(item)

    # Recursively sort the subarrays
    return quicksort(less) + equal + quicksort(greater)

This quicksort function first sorts the array arr by choosing a pivot, then partitions the elements into three groups: elements less than, equal, and greater. It recursively sorts these subarrays and returns the final sorted result.

Please note that in a real-world applications, you might use a more complex version with a pivot selection to improve performance or handle edge cases better. This provided example is for understanding.

There is a bug in my inferencer. Fixed now.

It performs well. Thanks.

J22 changed discussion status to closed

Sign up or log in to comment