working ordering matrix A