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

Function sort_priority2

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

Source from the content-addressed store, hash-verified

66
67print("Example 3")
68def sort_priority2(numbers, group):
69 found = False # Flag initial value
70
71 def helper(x):
72 if x in group:
73 found = True # Flip the flag
74 return (0, x)
75 return (1, x)
76
77 numbers.sort(key=helper)
78 return found # Flag final value
79
80
81print("Example 4")

Callers 1

item_033.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected