PLUTO
al_sort_.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Internal routine to sort an integer array
5 
6  Internal routine to sort an integer array
7 
8  \author A. Malagoli (University of Chicago)
9  \date Jul 17, 1999
10 */
11 /* ///////////////////////////////////////////////////////////////////// */
12 #define swapi_(a,b) ( temp=(a), (a)=(b), (b)=temp)
13 
14 /* ********************************************************************* */
15 int AL_Sort_(int n, int *in, int *ind)
16 /*!
17  * Sort and array of integers
18  *
19  * This is a really simple implementation, since we do not really
20  * use this for large arrays.
21  *
22  * \param [in] n size of input array (integer)
23  * \param [in] in input array
24  * \param [in] ind array of the sorted index arrays (max to min)
25  *********************************************************************** */
26 {
27  register int i, temp;
28  int m, r, s;
29 
30  /* Start with the normal index ordering */
31  for(i=0;i<n;i++) ind[i]=i;
32 
33  m=0;
34  while(m<n) {
35  r = m;
36  s = in[m];
37  for(i=m+1;i<n;i++) if( in[ind[i]] > s ) { r=i; s=in[ind[i]]; }
38  swapi_(ind[m],ind[r]);
39  m++;
40  }
41  return 0;
42 }
static int n
Definition: analysis.c:3
#define swapi_(a, b)
Definition: al_sort_.c:12
#define s
int AL_Sort_(int n, int *in, int *ind)
Definition: al_sort_.c:15
int i
Definition: analysis.c:2