reordering connections on mem-dep matrices