Booth,
If you want to keep it in memory without reading files try this:
* First create a DS with all fields from the subfile and load it with the data from the file. This only needs to be done once.
* Next, create an array that can hold any data element from the subfile sortable columns and the index of the DS.
* Finally, create two procedures: 1. Load the subfile from the sorted array from top to bottom (Ascending) & 2. Load the subfile from bottom to top (Descending). In both of these procedures, use the index to find the correct element in the DS to load the subfile. Don't forget to skip blank
* Load the sorting array from the DS and sort. Then call the appropriate procedure to load the subfile in the proper order.
I would use logical files only when the number of records to load is too large to sort. Dynamic imbedded SQL would be even better. Just modify the Select string with the appropriate sort elements.
Thanks,
Marvin
----------------------------------------------------------------------
message: 1
date: Wed, 22 Oct 2008 09:34:55 -0500
from: Booth Martin <booth@xxxxxxxxxxxx>
subject: Sorting arrays
I'd enjoy following a discussion about sorting related arrays. I have
already solved the problem I am about to present, but as I look at my
solution it occurs to me that I am embarrassed to show my solution to
knowledgeable people. There _has_ to be a better way.
Here's the sceanrio: To display a multi-column load-all subfile and
have each column heading clickable. The click would determine which
column is sorted. A second click on a clicked column would sort the
column in the other direction.
There are images of this at
http://www.martinvt.com/Code_Samples/SFL_Sort/sfl_sort.html
The code is also there. It works. But gads, its awful code.
So, lets define the problem a bit more? A load-all subfile with 5
columns of data How would one define the needed array(s), data
structure(s), or whatever(s) so that they can be sorted up or down by a
selected column?
--
---------------------------------
Booth Martin
http://www.Martinvt.com
---------------------------------
As an Amazon Associate we earn from qualifying purchases.