clustsort<-function(x){ xorder<-pull(x, 1)[hclust(dist(x %>% select(-1)))$order] yorder<-colnames(x)[2:ncol(x)][hclust(dist(t(x %>% select(-1))))$order] return(list("x"=xorder,"y"=yorder))}