public OrderedRowSet(RowSet sce, SSelectStatement sel, Context cx) : base(sce._tr, sel, sce._aggregates, sce.Length)
        {
            _sce = sce;
            var ti = SList <TreeInfo <Serialisable> > .Empty;
            int n  = 0;

            for (var b = sel.order.First(); b != null; b = b.Next())
            {
                ti = ti + (new TreeInfo <Serialisable>(b.Value, 'A', 'D', !b.Value.desc), n++);
            }
            var t = new SMTree <Serialisable>(ti);
            var r = SDict <int, SRow> .Empty;
            int m = 0;

            for (var b = sce.First() as RowBookmark; b != null; b = b.Next() as RowBookmark)
            {
                var k = new Variant[n];
                var i = 0;
                for (var c = sel.order.First(); c != null; c = c.Next())
                {
                    k[i] = new Variant(c.Value.col.Lookup(new Context(b, cx)), !c.Value.desc);
                }
                t  = t.Add(m, k);
                r += (m++, b._ob);
            }
            _tree = t;
            _rows = r;
        }
        public OrderedRowSet(RowSet sce, SList <TreeInfo <Serialisable> > ti, Context cx)
            : base(sce._tr, sce._qry, sce._aggregates, null)
        {
            _sce = sce;
            var t = new SMTree <Serialisable>(ti);
            var r = SDict <int, SRow> .Empty;
            int m = 0;

            for (var b = sce.First() as RowBookmark; b != null; b = b.Next() as RowBookmark)
            {
                var k = new Variant[ti.Length.Value];
                var i = 0;
                for (var c = ti.First(); c != null; c = c.Next())
                {
                    k[i] = new Variant(c.Value.headName.Lookup(new Context(b, cx)));
                }
                t  = t.Add(m, k);
                r += (m++, b._ob);
            }
            _tree = t;
            _rows = r;
        }
 static SMTree Add(SMTree t, string s, int i)
 {
     return(t.Add(i, V(s, 0), V(s, 1)));
 }