#!/bin/csh if (`flagLoc $argv -help`) then echo "List the index numbers which sort a (short) numeric list (slow!):" echo " sortRList.com 400.0 900.0 50.0 600.0 400.0 100.0 200.0 100.0" echo "Will return:" echo " 3 6 8 7 5 1 4 2" exit 0 endif set n = $#argv set iList = "" set kList = "" set rList = "" set i = 1 while ($i <= $n) set iList = ($iList $i) set kList = ($kList $i) set rList = ($rList $argv[$i]) @ i++ end foreach j ($iList) foreach i ($iList) if ($i > $j) then set ans = (`IMATH "$rList[$kList[$j]] > $rList[$kList[$i]]"`) if ($ans == 1) then set itemp = $kList[$j] set kList[$j] = $kList[$i] set kList[$i] = $itemp endif endif end end echo $kList