Describe the type of task carried out by the following algorithm.
The algorithm is an implementation of the quicksort algorithm, which is a sorting algorithm that recursively partitions an array into sub-arrays and sorts them until the entire array is sorted in ascending order. The algorithm selects a pivot element, then rearranges all the elements around the pivot so that smaller elements end up to the left, while larger elements end up on the right of the pivot. This process is repeated recursively until the entire array is sorted.
def quicksort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    middle = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]
    return quicksort(left) + middle + quicksort(right)
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
Describe the type of task carried out by the following algorithm.

### Input:
def quicksort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    middle = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]
    return quicksort(left) + middle + quicksort(right)

### Response:
The algorithm is an implementation of the quicksort algorithm, which is a sorting algorithm that recursively partitions an array into sub-arrays and sorts them until the entire array is sorted in ascending order. The algorithm selects a pivot element, then rearranges all the elements around the pivot so that smaller elements end up to the left, while larger elements end up on the right of the pivot. This process is repeated recursively until the entire array is sorted.