PLUTO
al_sort_.c File Reference

Internal routine to sort an integer array. More...

Go to the source code of this file.

Macros

#define swapi_(a, b)   ( temp=(a), (a)=(b), (b)=temp)
 

Functions

int AL_Sort_ (int n, int *in, int *ind)
 

Detailed Description

Internal routine to sort an integer array.

Internal routine to sort an integer array

Author
A. Malagoli (University of Chicago)
Date
Jul 17, 1999

Definition in file al_sort_.c.

Macro Definition Documentation

#define swapi_ (   a,
 
)    ( temp=(a), (a)=(b), (b)=temp)

Definition at line 12 of file al_sort_.c.

Function Documentation

int AL_Sort_ ( int  n,
int *  in,
int *  ind 
)

Sort and array of integers

This is a really simple implementation, since we do not really use this for large arrays.

Parameters
[in]nsize of input array (integer)
[in]ininput array
[in]indarray of the sorted index arrays (max to min)

Definition at line 15 of file al_sort_.c.

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 i
Definition: analysis.c:2

Here is the caller graph for this function: