My questions is :
There is a function that I can applied/use to sort EventTime column ?
note:The script above I put it on a button. when I click on a button, I can see data on this table.
but I would also like the script to run in real time instead of using a button.
You are running this very heavyweight function in a UI event routine. Expect client UI freezes.
Use an asynchronous thread to run this, and post the results back to the UI with invokeLater(). (Lots of discussions here on these techniques. Use them before you suffer for it.)
Well, no, that isn't a background (asynchronous) thread. invokeLater() runs the given function on the foreground thread--the same thread as the UI. You need system.util.invokeAsynchronous() to run in the background. The assignment to table.data is the part that needs to be on the foreground (because it operates on a GUI component--Swing requires that be in the foreground).
Consider using a Function Binding, instead of needing to do anything with scripting. You could bring the raw query dataset in on one custom property and use an expression function to sort the results for an efficient, easy to configure option.
BTW, your advice suggests that function bindings run asynchronously. I looked at using this extension point for some DB cache functionality, but couldn't tell if that were true. Hmmm?