def sortByNamespacePrefix(urisList, nsList):
    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
    for uri in urisList:
        if uri not in exit:
            exit += [uri]
    return exit