Hello,
Today I found a strange behavior of sortrev.
Here is the script:
H:\maciek\mk_test> type ss.py
import metakit as m
db = m.storage()
v = db.getas('a[x:S]')
for x in ['a', 'c', 'b']:
v.append(x=x)
def show (view, label):
print "%-4s: %s" % (label, " ".join([r.x for r in view]))
## Original view
show(v, "orig")
## Sorted by x
show(v.sort(v.x), "sort")
## Reverse sorted by x
show(v.sortrev((), (v.x,)), "rev")
## Now add a new property `idx' to the view with
## the same values as `x'
v.addproperty(m.property('S', 'idx'))
def mkidx(row):
row.idx = row.x
v.map(mkidx)
print
m.dump(v)
print
## Original view
show(v, "orig")
## Sorted by idx
show(v.sort(v.idx), "sort")
## Reverse sorted by idx
show(v.sortrev((), (v.idx,)), "rev")
And here is the output:
H:\maciek\mk_test> python ss.py
orig: a c b
sort: a b c
rev : c b a
x idx
- ---
a a
c c
b b
- ---
Total: 3 rows
orig: a c b
sort: a b c
rev : a b c
I was expecting the sorting on idx would have the
same effect as sorting on x. Sort looks good,
but sortrev seems to be broken. Could anyone
please explain it ?
Thanks,
Maciej
_______________________________________________
metakit mailing list - [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit