xHarbour Reference Documentation > Function Reference |
Retrieves the sort order of all keys in an associative array.
HGetVaaPos( <hArray> ) --> aSortOrder
The function returns a one dimensional array holding in its elements the numeric sort order of each key in <hArray>.
Function HGetVaaPos() iterates an associative array and collects the sort order of each key in a regular array, which is returned. This is equivalent to calling HaaGetRealPos() for all elements of <hArray>.
See also: | Array(), HaaGetKeyAt(), HaaGetPos(), HaaGetRealPos(), HaaGetValueAt(), HaaSetValueAt(), Hash(), HSetAACompatibility() |
Category: | Associative arrays , Hash functions , xHarbour extensions |
Source: | vm\hash.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example displays the ordinal position and the // sort order of keys in an associative array. PROCEDURE Main LOCAL hArray := Hash(), aSortOrder, i HSetAACompatibility( hArray, .T. ) hArray[ "One" ] := 10 hArray[ "Two" ] := 20 hArray[ "Three"] := 30 hArray[ "Four" ] := 40 hArray[ "Five" ] := 50 aSortOrder := HGetVAAPos( hArray ) FOR i :=1 TO Len( aSortOrder ) ? i, aSortOrder[i] NEXT ** Output: // 1 3 // 2 5 // 3 4 // 4 2 // 5 1 RETURN
http://www.xHarbour.com