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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sort real numbers 2

Status
Not open for further replies.

manoslev

Technical User
Dec 7, 2004
12
GR
Is there any way to sort real numbers from a lowest to a higher value ?
I am trying to do it with a do loop but it doesn't perform well when assigning real values to start,stop and increasing arguments of do loop.
I am using F90
 
If you publish the routine used for sorting, maybe someone can tell you what is wrong with it.
 
Hello

You can find Fortran-routines for sorting numbers on the web, for instance:
Here is also one old subroutine using the SHELL-SORT method:

Subroutine SORT(d,max)

c SHELL SORT

real*8 x,d(*)
integer*4 max

m = 1
20 if((2**m).gt.max) goto 30
m = m+1
goto 20
30 m = m-1
m = 2**m
100 k = max-m
do 500 i=1,k
do 300 j=i,1,(-m)
if(d(j+m).ge.d(j)) goto 500
x = d(j)
d(j) = d(j+m)
d(j+m) = x
300 continue
500 continue
m = m/2
if(m.gt.0) goto 100

return
end
 
I'd say, check on the docs of your compiler. As this is an everyday problem, your compiler might have some functions included for this job. In Salford FTN95 there are the functions rsort@, dsort@ and isort@ for sorting real, double and integer arrays respectively. In Compacq VC there is the sortqq function.

Norbert
 
Sorry, I misspelled

In Compacq VC there is the sortqq function.

means

In Compacq VF there is...

Norbert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top