nodes: 0, module; 1, function_definition; 2, function_name:sortByNamespacePrefix; 3, parameters; 4, block; 5, identifier:urisList; 6, identifier:nsList; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, comment:# add remaining uris (if any); 12, for_statement; 13, return_statement; 14, comment:"""
          Given an ordered list of namespaces prefixes, order a list of uris based on that.
          Eg
  
          In [7]: ll
          Out[7]:
          [rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
           rdflib.term.URIRef(u'printGenericTreeorg/2000/01/rdf-schema#comment'),
           rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'),
           rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass')]
  
          In [8]: sortByNamespacePrefix(ll, [OWL.OWLNS, RDFS])
          Out[8]:
          [rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass'),
           rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#comment'),
           rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'),
           rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')]
  
      """; 15, assignment; 16, assignment; 17, identifier:ns; 18, identifier:nsList; 19, block; 20, identifier:uri; 21, identifier:urisList; 22, block; 23, identifier:exit; 24, identifier:exit; 25, list; 26, identifier:urisList; 27, call; 28, expression_statement; 29, for_statement; 30, expression_statement; 31, if_statement; 32, identifier:sort_uri_list_by_name; 33, argument_list; 34, assignment; 35, identifier:uri; 36, identifier:urisList; 37, block; 38, augmented_assignment; 39, comparison_operator:uri not in exit; 40, block; 41, identifier:urisList; 42, identifier:innerexit; 43, list; 44, if_statement; 45, identifier:exit; 46, identifier:innerexit; 47, identifier:uri; 48, identifier:exit; 49, expression_statement; 50, call; 51, block; 52, augmented_assignment; 53, attribute; 54, argument_list; 55, expression_statement; 56, identifier:exit; 57, list; 58, call; 59, identifier:startswith; 60, call; 61, augmented_assignment; 62, identifier:uri; 63, identifier:str; 64, argument_list; 65, identifier:str; 66, argument_list; 67, identifier:innerexit; 68, list; 69, identifier:uri; 70, identifier:ns; 71, identifier:uri
code: def sortByNamespacePrefix(urisList, nsList):
      """
          Given an ordered list of namespaces prefixes, order a list of uris based on that.
          Eg
  
          In [7]: ll
          Out[7]:
          [rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
           rdflib.term.URIRef(u'printGenericTreeorg/2000/01/rdf-schema#comment'),
           rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'),
           rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass')]
  
          In [8]: sortByNamespacePrefix(ll, [OWL.OWLNS, RDFS])
          Out[8]:
          [rdflib.term.URIRef(u'http://www.w3.org/2002/07/owl#equivalentClass'),
           rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#comment'),
           rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'),
           rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')]
  
      """
      exit = []
      urisList = sort_uri_list_by_name(urisList)
      for ns in nsList:
          innerexit = []
          for uri in urisList:
              if str(uri).startswith(str(ns)):
                  innerexit += [uri]
          exit += innerexit
  
      # add remaining uris (if any)
      for uri in urisList:
          if uri not in exit:
              exit += [uri]
  
      return exit