My program generates orthogonal null space vectors such as this:
{{0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
{0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0},
{0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0},
{1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1},
{0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0}}
.
My goal is to find the ordering which looks at the first occurrence of 1 within the vector. The desired ordering for the above is {5,1,2,6,3,4}
corresponding to
{{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
{0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0}}
Primitive attempts using Ordering
and Sort
have failed; my hope is someone can save me from the faux pas of a Do
loop.
Reverse[Ordering[vecs]]
? $\endgroup$