def marker_comparator(matches, markers):
 def comparator(marker1, marker2):
  '\n        The actual comparator function.\n        '
  matches_count = (marker_weight(matches, marker2) - marker_weight(matches, marker1))
  if matches_count:
   return matches_count
  len_diff = (len(marker2) - len(marker1))
  if len_diff:
   return len_diff
  return (markers.index(marker2) - markers.index(marker1))
 return comparator

def marker_comparator ( matches , markers ) : def comparator ( marker1 , marker2 ) : matches_count = ( marker_weight ( matches , marker2 ) - marker_weight ( matches , marker1 ) ) if matches_count : return matches_count len_diff = ( len ( marker2 ) - len ( marker1 ) ) if len_diff : return len_diff return ( markers . index ( marker2 ) - markers . index ( marker1 ) ) return comparator
builds a comparator that returns markers sorted from the most valuable to the less .