Sorry, I don’t think I understand, what do you mean by “check if the three sub lists can combine into one sorted list.” Is it possible if you can give an example?
After the for loop splits the original list into three lists, maybe check if the recombined list is sorted. If it isn’t then call the quick_sort function with the unsorted list.
They’re saying you need to check if the result of the looped-over ‘if/elif/else’ chain is sorted, otherwise the function needs to be called again, to continue the sorting.
Right now, if I’m understanding your code correctly, the sorting only happens once. So with that array example of [20, 3, 14, 1, 5] that is in your code, the results should look something like
less_than_pivot: [3, 14, 1, 5]
equal_to_pivot: [20]
greater_than_pivot: []
If you were to concatenate those three resulting arrays together, it would be [3, 14, 1, 5, 20], which is not a fully sorted array (this is what you need to determine in your code), and so the sorting method should be called again until it is fully sorted.
I combined all three sublists and got [3, 14, 1, 5, 20] as my result, so I called the quick_sort method on the combined list. But when I do that I get an error on the terminal saying: [Previous line repeated 993 more times]
File “main.py”, line 10, in quick_sort
RecursionError: maximum recursion depth exceeded in comparison.