NV5 GEOSPATIAL SOFTWARE
>  Docs Center  >  Libraries  >  Markwardt  >  MULTISORT

MULTISORT

MULTISORT

## Author

Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
craigm@lheamail.gsfc.nasa.gov

## Purpose

Perform a sorting operation with multiple sort keys

## Calling Sequence

INDICES = MULTISORT(KEY1, KEY2, ..., [/L64, ], [ORDER=order])

## Description

The function MULTISORT performs a sorting operation with multiple
sort keys. Unlike the IDL built-in SORT() function, which can
only sort a single key, MULTISORT can accept multiple keys. In
cases where the primary key is equal, the sort order is based on
any secondary keys provided. The return value is an array of
indices which will place the key arrays into sorted order.
MULTISORT works by building an internal sort key string which can
be sorted in a single pass. Because MULTISORT is not a built-in
function, and because it must build these auxiliary strings, it
cannot be as fast or memory-efficient as the built-in function.
Users will need several times more memory than the memory used
to store just the input keys.
MULTISORT() allows the user to choose the sort order for each key
separately. The ORDER keyword is an N-vector, one order for each
input key. ORDER[i] is +1 to sort KEYi ascending, and ORDER[i] is
-1 to sort KEYi descending.

## Inputs

KEY1, KEY2, ... KEY9 - input sort keys. Any integer, floating
point or string value is allowed. The
number of values must be the same for each
key.

## Keywords

ORDER - an N-vector, giving the sort order for each key (see
documentation above).
Default: REPLICATE(+1,N_PARAMS()) (all keys ascending)
L64 - if set, then return a LONG64 index instead of LONG.

## Returns

An array of indices which will place the keys into sorted order.
I.e., KEYS1[INDICES], KEYS2[INDICES] ... will be in order.

SORT

## Modification History

Written, CM, Jun 2007
Document the encoding format, and make some floating point
operations more efficient, CM, Jan 2008
Correct several bugs in the handling of floating point numbers
in the range -1.0 to 1.0, made more efficient, (thanks to Eric
Jensen); I also saved some test cases; CM, Jul 2008

© 2024 NV5 Geospatial Solutions, Inc. |  Legal