mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
Reverse argument order for nsmallest() and nlargest().
Reads better when the iterable is a generator expression.
This commit is contained in:
parent
969297f488
commit
aefde435ef
4 changed files with 9 additions and 9 deletions
|
@ -705,7 +705,7 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
|
|||
result.append((s.ratio(), x))
|
||||
|
||||
# Move the best scorers to head of list
|
||||
result = heapq.nlargest(result, n)
|
||||
result = heapq.nlargest(n, result)
|
||||
# Strip scores for the best n matches
|
||||
return [x for score, x in result]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue