This rule raises an issue when the reversed() function is called with a sorted() as an argument.

Why is this an issue?

The sorted() function has a reverse parameter that provides the same functionality as the reversed() function.

How to fix it

Use the reverse parameter of the sorted() function to sort in descending order instead of using reversed().

Code examples

Noncompliant code example

data = [3, 1, 4, 1, 5, 9]
result = reversed(sorted(data)) # Noncompliant

Compliant solution

data = [3, 1, 4, 1, 5, 9]
result = sorted(data, reverse=True)

Resources

Documentation