Merge "Use new sorting mechanism." into tm-dev