More efficient nesting

Instead of nesting by trial id, just sort by trial id