Clustering and alignment of a functional dataset