/* DEC **SortDecimal(dst, src, n, opt); * * ARGUMENT * DEC **dst; * DEC **src; * int n; * int opt; * * DESCRIPTION * Sorts an array in increasing or decreasing order. The n elements * of src are sorted and stored in dst. opt is GM_INC if the elements * should be sorted in increasing order, and opt is GM_DEC is the elements * should be sorted in decreasing order. * A temporary copy of the array is allocated by this procedure. * * SIDE EFFECTS * None. * * RETURNS * dst if successful, otherwise GM_NULL * * POSSIBLE ERRORS * GM_NULLPOINTER * GM_INIT * GM_NOMEMORY * * AUTHOR * Jared Levy * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. * * MODIFICATIONS * * */ #include #include #include "gmsystem.h" DEC **SortDecimalArray(dst, src, n, opt) DEC **dst, **src; int n, opt; { DEC *tmpd, **tmpa, *p; int i; extern void qsort(char *, unsigned, unsigned, int (*)()); _MacStart(GM_DSORT); if (n<0|| (opt!=GM_INC && opt!=GM_DEC)) { _MacErr(GM_ARGVAL); _MacRet(GM_NULLARR); } if (!src||!dst) { _MacErr(GM_NULLPOINTER); _MacRet(GM_NULLARR); } if (n==0) _MacRet(dst); for (i=0;i