---
source: crates/ruff_linter/src/rules/refurb/mod.rs
---
FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence
 --> FURB192.py:3:1
  |
1 | # Errors
2 |
3 | sorted(l)[0]
  | ^^^^^^^^^^^^
4 |
5 | sorted(l)[-1]
  |
help: Replace with `min`
  |
2 |
  - sorted(l)[0]
3 + min(l)
4 |
  |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence
 --> FURB192.py:5:1
  |
3 | sorted(l)[0]
4 |
5 | sorted(l)[-1]
  | ^^^^^^^^^^^^^
6 |
7 | sorted(l, reverse=False)[-1]
  |
help: Replace with `max`
  |
4 |
  - sorted(l)[-1]
5 + max(l)
6 |
  |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence
 --> FURB192.py:7:1
  |
5 | sorted(l)[-1]
6 |
7 | sorted(l, reverse=False)[-1]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 |
9 | sorted(l, key=lambda x: x)[0]
  |
help: Replace with `max`
  |
6 |
  - sorted(l, reverse=False)[-1]
7 + max(l)
8 |
  |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence
  --> FURB192.py:9:1
   |
 7 | sorted(l, reverse=False)[-1]
 8 |
 9 | sorted(l, key=lambda x: x)[0]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 |
11 | sorted(l, key=key_fn)[0]
   |
help: Replace with `min`
   |
8  |
   - sorted(l, key=lambda x: x)[0]
9  + min(l, key=lambda x: x)
10 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence
  --> FURB192.py:11:1
   |
 9 | sorted(l, key=lambda x: x)[0]
10 |
11 | sorted(l, key=key_fn)[0]
   | ^^^^^^^^^^^^^^^^^^^^^^^^
12 |
13 | sorted([1, 2, 3])[0]
   |
help: Replace with `min`
   |
10 |
   - sorted(l, key=key_fn)[0]
11 + min(l, key=key_fn)
12 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence
  --> FURB192.py:13:1
   |
11 | sorted(l, key=key_fn)[0]
12 |
13 | sorted([1, 2, 3])[0]
   | ^^^^^^^^^^^^^^^^^^^^
14 |
15 | # Unsafe
   |
help: Replace with `min`
   |
12 |
   - sorted([1, 2, 3])[0]
13 + min([1, 2, 3])
14 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence
  --> FURB192.py:17:1
   |
15 | # Unsafe
16 |
17 | sorted(l, key=key_fn, reverse=True)[-1]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
19 | sorted(l, reverse=True)[0]
   |
help: Replace with `min`
   |
16 |
   - sorted(l, key=key_fn, reverse=True)[-1]
17 + min(l, key=key_fn)
18 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence
  --> FURB192.py:19:1
   |
17 | sorted(l, key=key_fn, reverse=True)[-1]
18 |
19 | sorted(l, reverse=True)[0]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
20 |
21 | sorted(l, reverse=True)[-1]
   |
help: Replace with `max`
   |
18 |
   - sorted(l, reverse=True)[0]
19 + max(l)
20 |
   |
note: This is an unsafe fix and may change runtime behavior

FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence
  --> FURB192.py:21:1
   |
19 | sorted(l, reverse=True)[0]
20 |
21 | sorted(l, reverse=True)[-1]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
22 |
23 | # Non-errors
   |
help: Replace with `min`
   |
20 |
   - sorted(l, reverse=True)[-1]
21 + min(l)
22 |
   |
note: This is an unsafe fix and may change runtime behavior
