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