nodes: 0, module; 1, function_definition; 2, function_name:_filter_sources; 3, parameters; 4, block; 5, identifier:self; 6, identifier:sources; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Remove sources with errors and return ordered by host success.
  
          :param sources: List of potential sources to connect to.
          :type sources: list
          :returns: Sorted list of potential sources without errors.
          :rtype: list
          """; 12, assignment; 13, identifier:source; 14, identifier:sources; 15, block; 16, call; 17, pattern_list; 18, expression_list; 19, if_statement; 20, expression_statement; 21, expression_statement; 22, identifier:sorted; 23, argument_list; 24, identifier:filtered; 25, identifier:hosts; 26, list; 27, list; 28, comparison_operator:'error' in source; 29, block; 30, call; 31, call; 32, identifier:filtered; 33, keyword_argument; 34, string; 35, identifier:source; 36, continue_statement; 37, attribute; 38, argument_list; 39, attribute; 40, argument_list; 41, identifier:key; 42, lambda; 43, string_content:error; 44, identifier:filtered; 45, identifier:append; 46, identifier:source; 47, identifier:hosts; 48, identifier:append; 49, subscript; 50, lambda_parameters; 51, call; 52, identifier:source; 53, string; 54, identifier:s; 55, attribute; 56, argument_list; 57, string_content:host_name; 58, call; 59, identifier:index; 60, subscript; 61, attribute; 62, argument_list; 63, identifier:s; 64, string; 65, identifier:self; 66, identifier:_hosts_by_success; 67, identifier:hosts; 68, string_content:host_name
code: def _filter_sources(self, sources):
          """Remove sources with errors and return ordered by host success.
  
          :param sources: List of potential sources to connect to.
          :type sources: list
          :returns: Sorted list of potential sources without errors.
          :rtype: list
          """
          filtered, hosts = [], []
          for source in sources:
              if 'error' in source:
                  continue
              filtered.append(source)
              hosts.append(source['host_name'])
  
          return sorted(filtered, key=lambda s:
                        self._hosts_by_success(hosts).index(s['host_name']))