# Finding a Variable Name in an Array ? (AS3)

**URL:** <https://forum.kirupa.com/t/finding-a-variable-name-in-an-array-as3/307845>\
**Category:** flash\
**Created:** [April 12, 2010, 12:19am UTC](https://forum.kirupa.com/t/finding-a-variable-name-in-an-array-as3/307845 "2010-04-12T00:19:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scheisse](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Scheisse](https://forum.kirupa.com/u/Scheisse)\
**Post date:** [April 12, 2010, 12:19am UTC](https://forum.kirupa.com/t/finding-a-variable-name-in-an-array-as3/307845/1 "2010-04-12T00:19:49Z")

</div>

Hi, I have an array with about 80 variables in it and everything is working fine, but I can’t seem to figure out how to produce a variable name from the array.

Example: I sort my array to get the highest value, then I cannot retrieve the actual name of the variable that holds the value.

var p1:Number = 1;  
var p2:Number = 2;

var pArray:Array = new Array(p1,p2);  
pArray.sort(Array.DESCENDING | ARRAY.NUMERIC);

trace(pArray[0]);

I will get “2”, but I want it to say “p2”.

I looked into “toString” and toLocaleString but they also gives me the number value.
