<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def best_match(self, matches, default=None):
 """Returns the best match from a list of possible matches based on the quality of the client. If two items have the same quality, the one is returned that comes first. :param matches: a list of matches to check for :param default: the value that is returned if none match """

        if matches:
            best_quality = -1
            result = default
            for client_item, quality in self:
                for server_item in matches:
                    if quality <= best_quality:
                        break
                    if self._value_matches(server_item, client_item):
                        best_quality = quality
                        result = server_item
            return result
        else:
            return self.best