Explanation: Lets take the example numbers: 4, 3, 11, 19, 35, 41, 73, 43, 81, 72, 87, 11. I need to know what order the numbers should be in, in order to rank them (for anyone interested, its for spearmans rank). This returns a list of indexs, in order.

#include<array.au3> Local $aArray[12] = [4, 3, 11, 19, 35, 41, 73, 43, 81, 72, 87, 114] $temp = _ArrayGetOrder ($aArray) MsgBox (0, "Result", $temp) ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayGetOrder ; Description ...: Returns a list of the indexes ordered by their value ; Syntax.........: _ArrayGetOrder ($aArray[, $iStart = 0[, $iEnd = 0[, $nRetType = 0]]]) ; Parameters ....: $avArray - Array to search ; $iStart - [optional] Index of array to start searching at ; $iEnd - [optional] Index of array to stop searching at ; $nRetType - [optional] If 1, will return An Array showing the indexs of the array ordered. (zero based) ; Return values .: Success - the list as a string ("," comma seperated.) ; Failure - -1, sets @error: ; |1 - $avArray is not an array ; |2 - $iStart is greater than $iEnd ; |3 - $avArray is not a 1 dimensional array ; |4 - Value is not of numeric type. @Extended holds the index ; Author ........: Mat ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _ArrayGetOrder ($aArray, $iStart = 0, $iEnd = 0, $nRetType = 0) If Not IsArray($aArray) Then Return SetError(1, 0, -1) If UBound($aArray, 0) <> 1 Then Return SetError(3, 0, -1) Local $iUBound = UBound($aArray) - 1 ; Bounds checking If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(2, 0, -1) Local $temp = "" For $i = $iStart to $iEnd $iMaxIndex = 0 If Not IsNumber ($aArray[$i]) Then Return SetError (4, $i, -1) For $x = $iStart To $iEnd If $aArray[$iMaxIndex] < $aArray[$x] Then $iMaxIndex = $x Next $temp &= "," & $iMaxIndex $aArray[$iMaxIndex] = 0 Next $temp = StringTrimLeft ($temp, 1) If $nRetType = 0 then return $temp Return StringSplit ($temp, ",", 2) EndFunc ; ==> _ArrayGetOrder

I better explain exactly what I mean by 'ranking':

Yellow is what I call the ranking, and s what it returned by this function. Green is what would be returned by _ArraySort.

Mat

**Edited by Mat, 08 April 2011 - 09:47 PM.**