Define a function sort_list(list1) that returns the original list, the list in ascending order, and the list in descending order.
时间: 2024-02-15 08:02:21 浏览: 88
Sure, here's the code for the function you requested:
```python
def sort_list(list1):
sorted_list = sorted(list1)
reverse_sorted_list = sorted(list1, reverse=True)
return list1, sorted_list, reverse_sorted_list
```
This function takes a list as the input argument and uses the `sorted()` function to generate a new list that is sorted in ascending order. It then uses the same function with the `reverse` parameter set to `True` to generate a new list that is sorted in descending order. Finally, it returns a tuple containing the original list, the sorted list, and the reverse sorted list.
阅读全文