# coyote: SORT_ND

- [Source code]

NAME

      SORT_ND

PURPOSE

      Efficiently perform an N-dimensional sort along any dimension
      of an array.

CALLING SEQUENCE

      inds=sort_nd(array,dimension)

INPUTS

      array: An array of at least 2 dimensions to sort.
      dimension: The dimension along which to sort, starting at 1
         (1:rows, 2:columns, ...).

OUTPUTS

      inds: An index array with the same dimensions as the input
         array, containing the (1D) sorted indices.  Can be used
         directly to index the arary (ala SORT).

EXAMPLE

      a=randomu(sd,5,4,3,2)
      sorted=a[sort_nd(a,2)]

SEE ALSO

      HISTOGRAM

MODIFICATION HISTORY

      Tue Aug 22 15:51:12 2006, J.D. Smith <jdsmith@as.arizona.edu>
      ten, based on discussion on c.l.i-p, 08/2006.