Help me in solving DSSA107 problem

My issue

it showing time limit exceeded

My code

import random
def randomized_quick_sort(arr):
    if len(arr) <= 1:
        return arr

    pivot_index = random.randint(0, len(arr) - 1)
    pivot = arr[pivot_index]
    
    less_than_pivot = [x for x in arr if x < pivot]
    equal_to_pivot = [x for x in arr if x == pivot]
    greater_than_pivot = [x for x in arr if x > pivot]

    return randomized_quick_sort(less_than_pivot) + equal_to_pivot + randomized_quick_sort(greater_than_pivot)

# Input
t = int(input())
results = []

for _ in range(t):
    n = int(input())
    arr = list(map(int, input().split()))
    sorted_arr = randomized_quick_sort(arr)
    results.append(sorted_arr)

# Output
for result in results:
    print(*result)

Learning course: Kalasalingam Academy of Research and Education
Problem Link: CodeChef: Practical coding for everyone