/*
* reorder the tuple to put x's line first in the entry and x first in its line
*/
Ndbtuple*
ndbreorder(Ndbtuple *t, Ndbtuple *x)
{
Ndbtuple *nt;
Ndbtuple *last, *prev;
/* if x is first, we're done */
if(x == t)
return t;
/* find end of x's line */
for(last = x; last->line == last->entry; last = last->line)
;
/* rotate to make this line first */
if(last->line != t){
/* detach this line and everything after it from the entry */
for(nt = t; nt->entry != last->line; nt = nt->entry)
;
nt->entry = nil;