View previous topic :: View next topic |
Author |
Message |
imdaboss Beginner
Joined: 10 Jan 2006 Posts: 3 Topics: 1
|
Posted: Tue Jan 10, 2006 12:58 pm Post subject: Sort a stem |
|
|
Hello,
I've a REXX program which has an internal stem that contains strings.
The thing is I need to sort the stem and I was wondering what is the best way to do it.
I could do a selection sort algorithm or something, but I would be re-inventing (or in this case re-doing) the wheel, and I don't know if there are some other ways to do it that also have better performance.
Thanks in advance for any answers. |
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Tue Jan 10, 2006 1:13 pm Post subject: |
|
|
It depends on the platform you are using and the amount of data. There are certainly many implementations of various sorts in Rexx available through a web search. For small amounts of data a simple bubble sort is fast enough. For larger amounts, one of the other sorts may be better. Lots of people use one of the quicksort implementations, but be aware that quicksort is lousy if the data is mostly sorted already.
On Windows or Linux or probably others, if you are using object rexx, stem sort is built in to the language. On z/OS, you'll need to either use your own alogithm or an external funciton. The Rexxtools (commercial) package has a stemsort function, or you can write your own in assembler or similar using the execcomm interfaces.
My guess is that in 99% of the cases, a simple inline sort (your choice of algorithm) will be fine. |
|
Back to top |
|
|
German Castillo Beginner
Joined: 23 Dec 2005 Posts: 83 Topics: 2 Location: Caracas, Venezuela
|
Posted: Tue Jan 10, 2006 1:18 pm Post subject: |
|
|
Hello imdaboss,
If the stem is very big, you should write it to a file and call DFSORT, but if the stem is notl, and you are willing to call your Rexx routine/macro inside an ISPF environment, you may place the stem in a ISPF table and use the TBSORt SERVICE.
Of course, you can allways write your own sort procedure _________________ Best wishes,
German Castillo |
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Tue Jan 10, 2006 3:29 pm Post subject: |
|
|
The problem with using ISPF tables is that rexx access of ISPF variables is very slow so for a table with many columns and/or rows, this can be very expensive. Populating and reading the table is the problem. The sort itself will still be fast. Large tables and Rexx are about the only time that Rexx is not a preferred language for ISPF development. |
|
Back to top |
|
|
imdaboss Beginner
Joined: 10 Jan 2006 Posts: 3 Topics: 1
|
Posted: Wed Jan 11, 2006 5:06 am Post subject: |
|
|
Seeing that the stem is not very big, I'll probably code an inline sort then.
Thank you for your replies. |
|
Back to top |
|
|
|
|