ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » What is the best way to deal with a sorted list.

Post new topic  Reply to topic
 What is the best way to deal with a sorted list. « View previous topic :: View next topic » 
Author Message
simon.starkie
PostPosted: Thu Feb 07, 2008 12:52 pm    Post subject: What is the best way to deal with a sorted list. Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu Feb 07, 2008 2:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
jharringa
PostPosted: Fri Feb 08, 2008 8:29 am    Post subject: Reply with quote

Acolyte

Joined: 24 Aug 2007
Posts: 70

A Java List has a sort() method that does a modified mergesort which will give you n log(n) performance. That being said, the elements within the list should implement the Comparable interface.

Here's the javadoc: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#sort(java.util.List)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » What is the best way to deal with a sorted list.
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.