I'd say, check on the docs of your compiler. As this is an everyday problem, your compiler might have some functions included for this job. In Salford FTN95 there are the functions rsort@, dsort@ and isort@ for sorting real, double and integer arrays respectively. In Compacq VC there is the sortqq function.
Norbert