Author |
Message
|
sarathmattam |
Posted: Tue Oct 07, 2008 11:09 pm Post subject: Sorting Function in ESQL |
|
|
Voyager
Joined: 05 Sep 2008 Posts: 94
|
Hi All,
My requirement is as given below
I have an array with 10 date values. I need to get the latest one out of it with out comparing individual dates.
Is there any FUNCTION in ESQL which will sort the date or Integers??
Pls reply ASAP.. Thanks a lot in Advance..
Regards,
Sarath |
|
Back to top |
|
 |
broker_new |
Posted: Fri Oct 10, 2008 6:31 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
There is no FUNCTION to perform that.
We have done research on that and found QUICK sort algorithm is the efficient one |
|
Back to top |
|
 |
tomshen |
Posted: Tue Nov 04, 2008 11:01 pm Post subject: so, How to write code of QUICKSORT algotithm in ESQL? |
|
|
Newbie
Joined: 04 Nov 2008 Posts: 1
|
Please do me a favor. Thank you.  |
|
Back to top |
|
 |
Esa |
Posted: Wed Nov 05, 2008 8:08 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
If you need to sort something in the message, just write a java class with a static method that uses java collections for sorting and wrap it with an ESQL LANGUAGE JAVA wrapper and you can call it from your ESQL code. |
|
Back to top |
|
 |
mqsiuser |
Posted: Tue Mar 30, 2010 11:48 pm Post subject: QuickSort in ESQL |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
|
Back to top |
|
 |
rsaavedra |
Posted: Mon Jun 23, 2014 12:20 pm Post subject: Order Qicksort |
|
|
Newbie
Joined: 23 Jun 2014 Posts: 4
|
How I can use QuickSort in order with more than one criterion? and the "element" is not a property but a value of a tag.
thanks-
 |
|
Back to top |
|
 |
mqsiuser |
Posted: Tue Jun 24, 2014 1:11 pm Post subject: Re: Order Qicksort |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
I tried to describe it here, anyway... we can discuss it in more detail:
1. Sort on one criteria, then sort again on the second
2. "Pre-process" the (message-)tree and create another element myRef.tmp = "criteria1__criteria2" (also for more criterias). "Post-process" when you are done (and remove the temporary criteria): myRef.tmp=NULL (requires you to loop over the list before & after)
3. Post your data and what you want to do (here on mqseries.net)
4. I am a contractor and available
Quote: |
and the "element" is not a property but a value of a tag. |
Broker uses the most simple and beautiful structure internally: The "logical message tree". Everything should be "element=value" (and metadata attached to it)
A value of a tag should be "tag=value"... anyway e.g. pre- and post-process (if you require a certain (different) structure temporarily). _________________ Just use REFERENCEs |
|
Back to top |
|
 |
rsaavedra |
Posted: Wed Jun 25, 2014 8:11 am Post subject: Example XML ordered two criteria |
|
|
Newbie
Joined: 23 Jun 2014 Posts: 4
|
Unordered XML
<message>
<header date="2010-03-17" time="16:02.123"/>
<list>
<element>
<criteria1>D</criteria1>
<criteria2>ABC</criteria2>
<criteria3>BC</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>A</criteria1>
<criteria2>ABC</criteria2>
<criteria3>C</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>F</criteria1>
<criteria2>ABC</criteria2>
<criteria3>BC</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>A</criteria1>
<criteria2>ABC</criteria2>
<criteria3>B</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>B</criteria1>
<criteria2>ABC</criteria2>
<criteria3>BC</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>A</criteria1>
<criteria2>ABC</criteria2>
<criteria3>A</criteria3>
<criteria4>A</criteria4>
<element>
</list>
</message>
XML Sorted by two criteria, criteria1 and criteria3
<message>
<header date="2010-03-17" time="16:02.123"/>
<list>
<element>
<criteria1>A</criteria1>
<criteria2>ABC</criteria2>
<criteria3>A</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>A</criteria1>
<criteria2>ABC</criteria2>
<criteria3>B</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>A</criteria1>
<criteria2>ABC</criteria2>
<criteria3>C</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>B</criteria1>
<criteria2>ABC</criteria2>
<criteria3>BC</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>D</criteria1>
<criteria2>ABC</criteria2>
<criteria3>BC</criteria3>
<criteria4>A</criteria4>
<element>
<element>
<criteria1>F</criteria1>
<criteria2>ABC</criteria2>
<criteria3>BC</criteria3>
<criteria4>A</criteria4>
<element>
</list>
</message>
thanks
[/code] |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Jun 25, 2014 8:26 am Post subject: Re: Example XML ordered two criteria |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Quicksort is stable
So when you sort(criteria3) and then sort(criteria1) it should have your desired outcome
That is option one ("1.")
... last criteria first... then move backwards _________________ Just use REFERENCEs |
|
Back to top |
|
 |
rsaavedra |
Posted: Wed Jun 25, 2014 8:38 am Post subject: Example XML ordered two criteria |
|
|
Newbie
Joined: 23 Jun 2014 Posts: 4
|
Then I must first sort the xml for the last criterion and so on until the first.
So if I have 3 criteria, I run three times a QuickSort?
Thank you |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Jun 25, 2014 8:46 am Post subject: Re: Example XML ordered two criteria |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
rsaavedra wrote: |
Then I must first sort the xml for the last criterion and so on until the first.
So if I have 3 criteria, I run three times a QuickSort?
Thank you |
Why don't you try it for yourself and see? You may well learn more about it that way. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
rsaavedra |
Posted: Wed Jun 25, 2014 8:51 am Post subject: Re: Example XML ordered two criteria |
|
|
Newbie
Joined: 23 Jun 2014 Posts: 4
|
smdavies99 wrote: |
rsaavedra wrote: |
Then I must first sort the xml for the last criterion and so on until the first.
So if I have 3 criteria, I run three times a QuickSort?
Thank you |
Why don't you try it for yourself and see? You may well learn more about it that way. |
I will do tests and let me tell you.
thanks |
|
Back to top |
|
 |
|