# Sorting orthogonal null space vectors

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.

• Perhaps Reverse[Ordering[vecs]] ? May 18, 2015 at 15:45
• Yes, that's it as Martimer has shown. Thanks to you both. May 18, 2015 at 16:26

Ordering[{{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}}]//Reverse

{5, 1, 2, 6, 3, 4}

{{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}}[[{5,1,2,6,3,4}]]

{{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}}