nodes: 0, module; 1, function_definition; 2, function_name:sort_uri_list_by_name; 3, parameters; 4, block; 5, identifier:uri_list; 6, default_parameter; 7, expression_statement; 8, function_definition; 9, try_statement; 10, identifier:bypassNamespace; 11, False; 12, comment:"""
       Sorts a list of uris
  
       bypassNamespace:
          based on the last bit (usually the name after the namespace) of a uri
          It checks whether the last bit is specified using a # or just a /, eg:
               rdflib.URIRef('http://purl.org/ontology/mo/Vinyl'),
               rdflib.URIRef('http://purl.org/vocab/frbr/core#Work')
  
       """; 13, function_name:get_last_bit; 14, parameters; 15, block; 16, block; 17, except_clause; 18, identifier:uri_string; 19, try_statement; 20, return_statement; 21, if_statement; 22, comment:# TODO: do more testing.. maybe use a unicode-safe method instead of __str__; 23, block; 24, block; 25, except_clause; 26, identifier:x; 27, identifier:bypassNamespace; 28, block; 29, else_clause; 30, expression_statement; 31, return_statement; 32, expression_statement; 33, block; 34, return_statement; 35, block; 36, call; 37, identifier:uri_list; 38, assignment; 39, expression_statement; 40, call; 41, return_statement; 42, identifier:print; 43, argument_list; 44, identifier:x; 45, subscript; 46, assignment; 47, identifier:sorted; 48, argument_list; 49, call; 50, string:"Error in <sort_uri_list_by_name>: possibly a UnicodeEncodeError"; 51, call; 52, integer:1; 53, identifier:x; 54, subscript; 55, identifier:uri_list; 56, keyword_argument; 57, identifier:sorted; 58, argument_list; 59, attribute; 60, argument_list; 61, call; 62, unary_operator; 63, identifier:key; 64, lambda; 65, identifier:uri_list; 66, identifier:uri_string; 67, identifier:split; 68, string:"#"; 69, attribute; 70, argument_list; 71, integer:1; 72, lambda_parameters; 73, call; 74, identifier:uri_string; 75, identifier:split; 76, string:"/"; 77, identifier:x; 78, identifier:get_last_bit; 79, argument_list; 80, call; 81, attribute; 82, argument_list; 83, identifier:x; 84, identifier:__str__
code: def sort_uri_list_by_name(uri_list, bypassNamespace=False):
      """
       Sorts a list of uris
  
       bypassNamespace:
          based on the last bit (usually the name after the namespace) of a uri
          It checks whether the last bit is specified using a # or just a /, eg:
               rdflib.URIRef('http://purl.org/ontology/mo/Vinyl'),
               rdflib.URIRef('http://purl.org/vocab/frbr/core#Work')
  
       """
  
      def get_last_bit(uri_string):
          try:
              x = uri_string.split("#")[1]
          except:
              x = uri_string.split("/")[-1]
          return x
  
      try:
          if bypassNamespace:
              return sorted(uri_list, key=lambda x: get_last_bit(x.__str__()))
          else:
              return sorted(uri_list)
      except:
          # TODO: do more testing.. maybe use a unicode-safe method instead of __str__
          print(
              "Error in <sort_uri_list_by_name>: possibly a UnicodeEncodeError")
          return uri_list