comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Sorting with IDL... Please give me any suggestions!!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Sorting with IDL... Please give me any suggestions!!! [message #52033 is a reply to message #52032] Thu, 21 December 2006 07:24 Go to previous message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
Your problem is that you cannot concatenate a string array that doesn't
contain only number strings with a number array. That's beside the
fact that you're concatenating them improperly. Not a bad idea to
store them in a structure.

file='score.txt'
lines=file_lines(file)
temp=strarr(2, lines)
openr, lun, /get_lun, file
readf, lun, temp
free_lun, lun
nm=temp[0, *]
sc=float(temp[1, *])
inds=sort(sc)
nm=nm[inds]
sc=sc[inds]

print, 'The Scores:'
for i=0, lines-1 do print, nm[i], sc[i]

And that's that

Braedley

DirtyHarry wrote:
> I am trying to learn the sort function in IDL. I would like to sort the
> final grades of my students in this semester.
>
> Jung 75
> Hyun 98
> Ji 95
> Young 92
> Chun 88
> Dong 89
> Joo 87
> Won 82
> Du 86
> Jin 84
>
> I saved these data in 'score.txt' file. I checked the sort function in
> IDL online help. The explanation was only for 1 dimensional array, but
> it was not useful for me. I just made a simple code like this, but it
> didn't work properly.
>
> ------------------------------------------
> pro grade
>
> nm = strarr(10)
> sr = fltarr(10)
> gr = [nm, sr]
> file='score.txt'
> openr, lun, file, /get_lun
> readf, lun, gr
>
> PRINT, 'Scores in sorted order: ', sr[SORT(sr)]
> print, gr, free_lun, lun
>
> end
>
> --------------------------
> I got a 'input conversion error' message and a blue arrow at line 8.
> Please let me know what to do. Give me any suggestions. Thanks.
[Message index]
 
Read Message
Read Message
Previous Topic: Sorting with IDL... Please give me any suggestions!!!
Next Topic: How to write applications in JAVA using IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 22:28:54 PDT 2025

Total time taken to generate the page: 2.00215 seconds