MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort a stem

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
imdaboss
Beginner


Joined: 10 Jan 2006
Posts: 3
Topics: 1

PostPosted: Tue Jan 10, 2006 12:58 pm    Post subject: Sort a stem Reply with quote

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
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Tue Jan 10, 2006 1:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
German Castillo
Beginner


Joined: 23 Dec 2005
Posts: 83
Topics: 2
Location: Caracas, Venezuela

PostPosted: Tue Jan 10, 2006 1:18 pm    Post subject: Reply with quote

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
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Tue Jan 10, 2006 3:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
imdaboss
Beginner


Joined: 10 Jan 2006
Posts: 3
Topics: 1

PostPosted: Wed Jan 11, 2006 5:06 am    Post subject: Reply with quote

Seeing that the stem is not very big, I'll probably code an inline sort then.

Thank you for your replies.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group