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

Home » Public Forums » archive » Re: sorting array column/rowwise
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 array column/rowwise [message #31322 is a reply to message #31321] Thu, 04 July 2002 06:42 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Marc Schellens (m_schellens@hotmail.com) writes:

> but I wanted to sort each column individually.
> Any guesses?

Here is how I would sort a column of an array.
But I think I would use the BSORT routine,
rather than the SORT routine if I was putting
it into a piece of code that mattered to me.

IDL> a=randomu(-3L, 3, 10)
IDL> print, a
0.897916 0.558249 0.766930
0.589101 0.0603181 0.973112
0.0378892 0.218058 0.142394
0.984703 0.894904 0.947651
0.804079 0.160385 0.208246
0.818130 0.103716 0.741117
0.0134482 0.0960160 0.692969
0.0230946 0.181693 0.0777949
0.269231 0.286594 0.730963
0.727624 0.272199 0.481930
IDL> s1 = sort(a[1,*])
IDL> a[1,*] = (a[1,*])[s1]
IDL> print, a
0.897916 0.0603181 0.766930
0.589101 0.0960160 0.973112
0.0378892 0.103716 0.142394
0.984703 0.160385 0.947651
0.804079 0.181693 0.208246
0.818130 0.218058 0.741117
0.0134482 0.272199 0.692969
0.0230946 0.286594 0.0777949
0.269231 0.558249 0.730963
0.727624 0.894904 0.481930

I expect that if I spent five more minutes on this
I could probably write a generalized program
that would sort on any column. :-)

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: gamma correction
Next Topic: write_jpeg and TVRD()

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

Current Time: Fri Oct 10 04:17:19 PDT 2025

Total time taken to generate the page: 0.72102 seconds