Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subroutine SORTQQ help

Status
Not open for further replies.

DimGio

Programmer
Feb 20, 2008
12
GR
If i have an array of let's say 1.000.000 elements. With subroutine SORTQQ i can sort the array in 0.2 sec while with other subroutines(not built in) it takes about 15 minutes. The problem is that i need to have an array with the initial location of the elements of the array.
Is there any way i can achieve this while using SORTQQ?
If there isn't do you know any other subroutine i can use which will be much faster?
 
SortQQ probably uses quicksort, quickersort or shell-mezner. What sorting technique are you using? From the timing, it sounds like you're using selection sort.

I don't quite understand what you mean by
I need to have an array with the initial location of the elements of the array

Could you give a simple example with say 10 items and say what is supposed to happen when you sort them
 
i will give you an example with 5 items(numbers)


Before sort : array = [ 1,3 4,7 0,23 5,78 1,26]
after sort : array = [ 0,23 1,26 1,3 4,7 5,86]

i need an additional array that will be : J = [ 3 5 1 2 4]

the location of the items(of the sorted array) in the array before the sorting..
The SORTQQ is a built in routine. I use DFLIB..Can i get an array 'J' by using this routine?
 
Can you not store them as

[1,3,1 4,7,2 0,23,3 5,78,4 1,26,5]

After the sort, you will get

[0,23,3 1,26,5, 1,3,1 4,7,2 5,78,4]

All you need to do is read off the last bit.

I don't know how you're proving the information for sorting. If it is a x,y set, are you doing something like

x * ymax + y

Could you make it

(x * ymax + y) * zmax + z?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top