1
/* @(#)sort.c 19.1 (ES0-DMD) 02/25/03 13:55:39 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
Corresponding concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
.COPYRIGHT (c) 1995 European Soutern Observatory
33
.AUTHOR P.Grosbol, IPG/ESO
35
.KEYWORDS sort, heapsort
36
.COMMENT Algorithm is adapted from 'Numerical Recipes in C' p.247
37
.VERSION 1.0 1995-Mar-09 : Creation, PJG
38
-----------------------------------------------------------------------*/
41
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42
.PURPOSE sort array in place using heapsort
44
-----------------------------------------------------------------------*/
45
int n; /* no. of elements in array */
46
float *ra; /* pointer to array to be sorted */
68
if (j<ir && ra[j]<ra[j+1]) ++j;