MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / TupleComp

Class TupleComp

tools/python-3.11.9-amd64/Lib/pstats.py:522–541  ·  view source on GitHub ↗

This class provides a generic function for comparing any two tuples. Each instance records a list of tuple-indices (from most significant to least significant), and sort direction (ascending or descending) for each tuple-index. The compare functions can then be used as the function

Source from the content-addressed store, hash-verified

520 print(func_std_string(func), file=self.stream)
521
522class TupleComp:
523 """This class provides a generic function for comparing any two tuples.
524 Each instance records a list of tuple-indices (from most significant
525 to least significant), and sort direction (ascending or descending) for
526 each tuple-index. The compare functions can then be used as the function
527 argument to the system sort() function when a list of tuples need to be
528 sorted in the instances order."""
529
530 def __init__(self, comp_select_list):
531 self.comp_select_list = comp_select_list
532
533 def compare (self, left, right):
534 for index, direction in self.comp_select_list:
535 l = left[index]
536 r = right[index]
537 if l < r:
538 return -direction
539 if l > r:
540 return direction
541 return 0
542
543
544#**************************************************************************

Callers 1

sort_statsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected