|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
What is the best way to deal with a sorted list. |
« View previous topic :: View next topic » |
Author |
Message
|
simon.starkie |
Posted: Thu Feb 07, 2008 12:52 pm Post subject: What is the best way to deal with a sorted list. |
|
|
Disciple
Joined: 24 Mar 2002 Posts: 180
|
I have a list called ProblemList.
The list is expected to contain about two hundred members.
The list is derived from an external data source
(in this case a web service, but it could just as easily be a database table)
Each member in the list contains three elements: problemName, problemId, dateOfRecord.
There is a requirement that the ProblemList be sorted.
The sort can be on any one or more of the three elements ( problemName, problemId, dateOfRecord).
What is the best, most efficient way of implementing the sort requirement?
The sorted ProblemList elements could be made available as leaves on a tree (i.e. LocalEnvironment).
One possibility would be to place the elements on the tree in the correct order using some sort of indexed offset based on a hash of the element or elements that the ProblemList needs to be sorted on. That is, the tree itself would be built and managed in "sort order" sequence. If that is even possible. This could be brittle.
Another possibility would be to place the elements on the tree in FIFO order and then somehow retrieve them in the correct sorted sequence. This would allow the most flexibility for supporting different sort criteria. I'm wondering if there is something analogous to a database sorted index but for automatically building a sorted index on WMB trees.
A third possibility would be a bubble sort.
Java provides the java.util.Arrays.sort but that may be tricky with a tree.
There may be other possibilities that are better
Thanks. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 07, 2008 2:34 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Bubble Sort, no matter who coded it, is never a possibility.
ESQL Select doesn't support GROUP BY, nor ORDER BY - nor does ESQL itself provide any primitive SORT functions.
The best way here is to have the web service source provide the data in sorted order...
The second best way is to use something other than java.util.Arrays.sort - if that really does a Bubble Sort? - use another utility function in Collections (I'm sure there is one). _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jharringa |
Posted: Fri Feb 08, 2008 8:29 am Post subject: |
|
|
Acolyte
Joined: 24 Aug 2007 Posts: 70
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|