sortId also applies to namespaces
Refactoring
updated version
Merge branch 'sortIdNs'