Recently started using the Simulation Aids module.
One thing I cannot figure out - doing a ORDER BY DESC type clause. I want to order by a datetime column in a dataset

and am trying to order by date descending.
I looked at the sample project and saw ORDER BY -t_stamp
and tried it with a hyphen like
view("* ORDER BY -Date_Entered", {Root Container.Table_Items.tableData})
but this gets me the error
Exception: Error executing expression binding on
List Records.Root Container.Table_Items.data
caused by ExpressionException: Unable to execute view
caused by Traceback (most recent call last):
File "<expression:view>", line 66, in <module>
TypeError: bad operand type for unary -: 'java.util.Date'
So I am not sure what I am missing here. I hope its ok to message you about this directly.
Tagging module creator @pturmel
The answer when the column is an object is to find a number conversion (or conversion to tuple of numbers). For dates, try adding .time
, like so:
view("* Order By -Date_Entered.time", ....)
1 Like
This worked for me, thanks Phil.
I don't have any idea how you're actually doing things, but you could potentially sneak in a check for Comparable, no?
If you look at the generated jython, you will realize I’m just using list.sort(), not any java action. Theoretically I could re-implement with a java code generator and transient classes, but that makes my head hurt.
1 Like
Since you’re here, before Phil responded I tried using system.dataset.sort()
to do this but this doesn’t seem to work on a java.util.Date type column. I don’t know if that’s expected or not.
system.dataset.sort
seems to work for me, in a quick test.
Hmm. Working for me too now. I must have done something wrong before. You can ignore that post.