MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / sort_priority3

Function sort_priority3

example_code/item_033.py:112–123  ·  view source on GitHub ↗
(numbers, group)

Source from the content-addressed store, hash-verified

110
111print("Example 7")
112def sort_priority3(numbers, group):
113 found = False
114
115 def helper(x):
116 nonlocal found # Added
117 if x in group:
118 found = True
119 return (0, x)
120 return (1, x)
121
122 numbers.sort(key=helper)
123 return found
124
125
126print("Example 8")

Callers 1

item_033.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected