Orders the partition so that mean values of fun applied to columns (if funWay=2, default), rows (if funWay=1) or both (if funWay=c(1,2)) is decreasing by clusters.
fun
funWay=2
funWay=1
funWay=c(1,2)
Useful links