<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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